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