4
4
5
5
package asymkey
6
6
7
- import "fmt"
7
+ import (
8
+ "fmt"
9
+ "io/fs"
10
+ )
8
11
9
12
// ErrKeyUnableVerify represents a "KeyUnableVerify" kind of error.
10
13
type ErrKeyUnableVerify struct {
@@ -36,6 +39,10 @@ func (err ErrKeyNotExist) Error() string {
36
39
return fmt .Sprintf ("public key does not exist [id: %d]" , err .ID )
37
40
}
38
41
42
+ func (err ErrKeyNotExist ) Unwrap () error {
43
+ return fs .ErrNotExist
44
+ }
45
+
39
46
// ErrKeyAlreadyExist represents a "KeyAlreadyExist" kind of error.
40
47
type ErrKeyAlreadyExist struct {
41
48
OwnerID int64
@@ -54,6 +61,10 @@ func (err ErrKeyAlreadyExist) Error() string {
54
61
err .OwnerID , err .Fingerprint , err .Content )
55
62
}
56
63
64
+ func (err ErrKeyAlreadyExist ) Unwrap () error {
65
+ return fs .ErrExist
66
+ }
67
+
57
68
// ErrKeyNameAlreadyUsed represents a "KeyNameAlreadyUsed" kind of error.
58
69
type ErrKeyNameAlreadyUsed struct {
59
70
OwnerID int64
@@ -70,6 +81,10 @@ func (err ErrKeyNameAlreadyUsed) Error() string {
70
81
return fmt .Sprintf ("public key already exists [owner_id: %d, name: %s]" , err .OwnerID , err .Name )
71
82
}
72
83
84
+ func (err ErrKeyNameAlreadyUsed ) Unwrap () error {
85
+ return fs .ErrExist
86
+ }
87
+
73
88
// ErrGPGNoEmailFound represents a "ErrGPGNoEmailFound" kind of error.
74
89
type ErrGPGNoEmailFound struct {
75
90
FailedEmails []string
@@ -132,6 +147,10 @@ func (err ErrGPGKeyNotExist) Error() string {
132
147
return fmt .Sprintf ("public gpg key does not exist [id: %d]" , err .ID )
133
148
}
134
149
150
+ func (err ErrGPGKeyNotExist ) Unwrap () error {
151
+ return fs .ErrNotExist
152
+ }
153
+
135
154
// ErrGPGKeyImportNotExist represents a "GPGKeyImportNotExist" kind of error.
136
155
type ErrGPGKeyImportNotExist struct {
137
156
ID string
@@ -147,6 +166,10 @@ func (err ErrGPGKeyImportNotExist) Error() string {
147
166
return fmt .Sprintf ("public gpg key import does not exist [id: %s]" , err .ID )
148
167
}
149
168
169
+ func (err ErrGPGKeyImportNotExist ) Unwrap () error {
170
+ return fs .ErrNotExist
171
+ }
172
+
150
173
// ErrGPGKeyIDAlreadyUsed represents a "GPGKeyIDAlreadyUsed" kind of error.
151
174
type ErrGPGKeyIDAlreadyUsed struct {
152
175
KeyID string
@@ -162,6 +185,10 @@ func (err ErrGPGKeyIDAlreadyUsed) Error() string {
162
185
return fmt .Sprintf ("public key already exists [key_id: %s]" , err .KeyID )
163
186
}
164
187
188
+ func (err ErrGPGKeyIDAlreadyUsed ) Unwrap () error {
189
+ return fs .ErrExist
190
+ }
191
+
165
192
// ErrGPGKeyAccessDenied represents a "GPGKeyAccessDenied" kind of Error.
166
193
type ErrGPGKeyAccessDenied struct {
167
194
UserID int64
@@ -180,6 +207,10 @@ func (err ErrGPGKeyAccessDenied) Error() string {
180
207
err .UserID , err .KeyID )
181
208
}
182
209
210
+ func (err ErrGPGKeyAccessDenied ) Unwrap () error {
211
+ return fs .ErrPermission
212
+ }
213
+
183
214
// ErrKeyAccessDenied represents a "KeyAccessDenied" kind of error.
184
215
type ErrKeyAccessDenied struct {
185
216
UserID int64
@@ -198,6 +229,10 @@ func (err ErrKeyAccessDenied) Error() string {
198
229
err .UserID , err .KeyID , err .Note )
199
230
}
200
231
232
+ func (err ErrKeyAccessDenied ) Unwrap () error {
233
+ return fs .ErrPermission
234
+ }
235
+
201
236
// ErrDeployKeyNotExist represents a "DeployKeyNotExist" kind of error.
202
237
type ErrDeployKeyNotExist struct {
203
238
ID int64
@@ -215,6 +250,10 @@ func (err ErrDeployKeyNotExist) Error() string {
215
250
return fmt .Sprintf ("Deploy key does not exist [id: %d, key_id: %d, repo_id: %d]" , err .ID , err .KeyID , err .RepoID )
216
251
}
217
252
253
+ func (err ErrDeployKeyNotExist ) Unwrap () error {
254
+ return fs .ErrNotExist
255
+ }
256
+
218
257
// ErrDeployKeyAlreadyExist represents a "DeployKeyAlreadyExist" kind of error.
219
258
type ErrDeployKeyAlreadyExist struct {
220
259
KeyID int64
@@ -231,6 +270,10 @@ func (err ErrDeployKeyAlreadyExist) Error() string {
231
270
return fmt .Sprintf ("public key already exists [key_id: %d, repo_id: %d]" , err .KeyID , err .RepoID )
232
271
}
233
272
273
+ func (err ErrDeployKeyAlreadyExist ) Unwrap () error {
274
+ return fs .ErrExist
275
+ }
276
+
234
277
// ErrDeployKeyNameAlreadyUsed represents a "DeployKeyNameAlreadyUsed" kind of error.
235
278
type ErrDeployKeyNameAlreadyUsed struct {
236
279
RepoID int64
@@ -247,6 +290,10 @@ func (err ErrDeployKeyNameAlreadyUsed) Error() string {
247
290
return fmt .Sprintf ("public key with name already exists [repo_id: %d, name: %s]" , err .RepoID , err .Name )
248
291
}
249
292
293
+ func (err ErrDeployKeyNameAlreadyUsed ) Unwrap () error {
294
+ return fs .ErrNotExist
295
+ }
296
+
250
297
// ErrSSHInvalidTokenSignature represents a "ErrSSHInvalidTokenSignature" kind of error.
251
298
type ErrSSHInvalidTokenSignature struct {
252
299
Wrapped error
@@ -262,3 +309,7 @@ func IsErrSSHInvalidTokenSignature(err error) bool {
262
309
func (err ErrSSHInvalidTokenSignature ) Error () string {
263
310
return "the provided signature does not sign the token with the provided key"
264
311
}
312
+
313
+ func (err ErrSSHInvalidTokenSignature ) Unwrap () error {
314
+ return fs .ErrInvalid
315
+ }
0 commit comments