...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package ociregistry
16
17
18 func NewError(msg string, code string, detail any) Error {
19 return ®istryError{
20 code: code,
21 message: msg,
22 detail: detail,
23 }
24 }
25
26
27
28
29
30 type Error interface {
31
32 error
33
34
35 Code() string
36
37
38
39 Detail() any
40 }
41
42
43 var (
44 ErrBlobUnknown = NewError("blob unknown to registry", "BLOB_UNKNOWN", nil)
45 ErrBlobUploadInvalid = NewError("blob upload invalid", "BLOB_UPLOAD_INVALID", nil)
46 ErrBlobUploadUnknown = NewError("blob upload unknown to registry", "BLOB_UPLOAD_UNKNOWN", nil)
47 ErrDigestInvalid = NewError("provided digest did not match uploaded content", "DIGEST_INVALID", nil)
48 ErrManifestBlobUnknown = NewError("manifest references a manifest or blob unknown to registry", "MANIFEST_BLOB_UNKNOWN", nil)
49 ErrManifestInvalid = NewError("manifest invalid", "MANIFEST_INVALID", nil)
50 ErrManifestUnknown = NewError("manifest unknown to registry", "MANIFEST_UNKNOWN", nil)
51 ErrNameInvalid = NewError("invalid repository name", "NAME_INVALID", nil)
52 ErrNameUnknown = NewError("repository name not known to registry", "NAME_UNKNOWN", nil)
53 ErrSizeInvalid = NewError("provided length did not match content length", "SIZE_INVALID", nil)
54 ErrUnauthorized = NewError("authentication required", "UNAUTHORIZED", nil)
55 ErrDenied = NewError("requested access to the resource is denied", "DENIED", nil)
56 ErrUnsupported = NewError("the operation is unsupported", "UNSUPPORTED", nil)
57 ErrTooManyRequests = NewError("too many requests", "TOOMANYREQUESTS", nil)
58
59
60
61
62
63
64
65
66 ErrRangeInvalid = NewError("invalid content range", "RANGE_INVALID", nil)
67 )
68
69 type registryError struct {
70 code string
71 message string
72 detail any
73 }
74
75 func (e *registryError) Code() string {
76 return e.code
77 }
78
79 func (e *registryError) Error() string {
80 return e.message
81 }
82
83 func (e *registryError) Detail() any {
84 return e.detail
85 }
86
View as plain text