Signed-off-by: Brian Goff <cpuguy83@gmail.com>
| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,74 +0,0 @@ |
| 1 |
-package errdefs |
|
| 2 |
- |
|
| 3 |
-// ErrNotFound signals that the requested object doesn't exist |
|
| 4 |
-type ErrNotFound interface {
|
|
| 5 |
- NotFound() |
|
| 6 |
-} |
|
| 7 |
- |
|
| 8 |
-// ErrInvalidParameter signals that the user input is invalid |
|
| 9 |
-type ErrInvalidParameter interface {
|
|
| 10 |
- InvalidParameter() |
|
| 11 |
-} |
|
| 12 |
- |
|
| 13 |
-// ErrConflict signals that some internal state conflicts with the requested action and can't be performed. |
|
| 14 |
-// A change in state should be able to clear this error. |
|
| 15 |
-type ErrConflict interface {
|
|
| 16 |
- Conflict() |
|
| 17 |
-} |
|
| 18 |
- |
|
| 19 |
-// ErrUnauthorized is used to signify that the user is not authorized to perform a specific action |
|
| 20 |
-type ErrUnauthorized interface {
|
|
| 21 |
- Unauthorized() |
|
| 22 |
-} |
|
| 23 |
- |
|
| 24 |
-// ErrUnavailable signals that the requested action/subsystem is not available. |
|
| 25 |
-type ErrUnavailable interface {
|
|
| 26 |
- Unavailable() |
|
| 27 |
-} |
|
| 28 |
- |
|
| 29 |
-// ErrForbidden signals that the requested action cannot be performed under any circumstances. |
|
| 30 |
-// When a ErrForbidden is returned, the caller should never retry the action. |
|
| 31 |
-type ErrForbidden interface {
|
|
| 32 |
- Forbidden() |
|
| 33 |
-} |
|
| 34 |
- |
|
| 35 |
-// ErrSystem signals that some internal error occurred. |
|
| 36 |
-// An example of this would be a failed mount request. |
|
| 37 |
-type ErrSystem interface {
|
|
| 38 |
- ErrSystem() |
|
| 39 |
-} |
|
| 40 |
- |
|
| 41 |
-// ErrNotModified signals that an action can't be performed because it's already in the desired state |
|
| 42 |
-type ErrNotModified interface {
|
|
| 43 |
- NotModified() |
|
| 44 |
-} |
|
| 45 |
- |
|
| 46 |
-// ErrAlreadyExists is a special case of ErrConflict which signals that the desired object already exists |
|
| 47 |
-type ErrAlreadyExists interface {
|
|
| 48 |
- AlreadyExists() |
|
| 49 |
-} |
|
| 50 |
- |
|
| 51 |
-// ErrNotImplemented signals that the requested action/feature is not implemented on the system as configured. |
|
| 52 |
-type ErrNotImplemented interface {
|
|
| 53 |
- NotImplemented() |
|
| 54 |
-} |
|
| 55 |
- |
|
| 56 |
-// ErrUnknown signals that the kind of error that occurred is not known. |
|
| 57 |
-type ErrUnknown interface {
|
|
| 58 |
- Unknown() |
|
| 59 |
-} |
|
| 60 |
- |
|
| 61 |
-// ErrCancelled signals that the action was cancelled. |
|
| 62 |
-type ErrCancelled interface {
|
|
| 63 |
- Cancelled() |
|
| 64 |
-} |
|
| 65 |
- |
|
| 66 |
-// ErrDeadline signals that the deadline was reached before the action completed. |
|
| 67 |
-type ErrDeadline interface {
|
|
| 68 |
- DeadlineExceeded() |
|
| 69 |
-} |
|
| 70 |
- |
|
| 71 |
-// ErrDataLoss indicates that data was lost or there is data corruption. |
|
| 72 |
-type ErrDataLoss interface {
|
|
| 73 |
- DataLoss() |
|
| 74 |
-} |
| 75 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,8 +0,0 @@ |
| 1 |
-// Package errdefs defines a set of error interfaces that packages should use for communicating classes of errors. |
|
| 2 |
-// Errors that cross the package boundary should implement one (and only one) of these interfaces. |
|
| 3 |
-// |
|
| 4 |
-// Packages should not reference these interfaces directly, only implement them. |
|
| 5 |
-// To check if a particular error implements one of these interfaces, there are helper |
|
| 6 |
-// functions provided (e.g. `Is<SomeError>`) which can be used rather than asserting the interfaces directly. |
|
| 7 |
-// If you must assert on these interfaces, be sure to check the causal chain (`err.Cause()`). |
|
| 8 |
-package errdefs |
| 9 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,240 +0,0 @@ |
| 1 |
-package errdefs |
|
| 2 |
- |
|
| 3 |
-import "context" |
|
| 4 |
- |
|
| 5 |
-type errNotFound struct{ error }
|
|
| 6 |
- |
|
| 7 |
-func (errNotFound) NotFound() {}
|
|
| 8 |
- |
|
| 9 |
-func (e errNotFound) Cause() error {
|
|
| 10 |
- return e.error |
|
| 11 |
-} |
|
| 12 |
- |
|
| 13 |
-// NotFound is a helper to create an error of the class with the same name from any error type |
|
| 14 |
-func NotFound(err error) error {
|
|
| 15 |
- if err == nil {
|
|
| 16 |
- return nil |
|
| 17 |
- } |
|
| 18 |
- return errNotFound{err}
|
|
| 19 |
-} |
|
| 20 |
- |
|
| 21 |
-type errInvalidParameter struct{ error }
|
|
| 22 |
- |
|
| 23 |
-func (errInvalidParameter) InvalidParameter() {}
|
|
| 24 |
- |
|
| 25 |
-func (e errInvalidParameter) Cause() error {
|
|
| 26 |
- return e.error |
|
| 27 |
-} |
|
| 28 |
- |
|
| 29 |
-// InvalidParameter is a helper to create an error of the class with the same name from any error type |
|
| 30 |
-func InvalidParameter(err error) error {
|
|
| 31 |
- if err == nil {
|
|
| 32 |
- return nil |
|
| 33 |
- } |
|
| 34 |
- return errInvalidParameter{err}
|
|
| 35 |
-} |
|
| 36 |
- |
|
| 37 |
-type errConflict struct{ error }
|
|
| 38 |
- |
|
| 39 |
-func (errConflict) Conflict() {}
|
|
| 40 |
- |
|
| 41 |
-func (e errConflict) Cause() error {
|
|
| 42 |
- return e.error |
|
| 43 |
-} |
|
| 44 |
- |
|
| 45 |
-// Conflict is a helper to create an error of the class with the same name from any error type |
|
| 46 |
-func Conflict(err error) error {
|
|
| 47 |
- if err == nil {
|
|
| 48 |
- return nil |
|
| 49 |
- } |
|
| 50 |
- return errConflict{err}
|
|
| 51 |
-} |
|
| 52 |
- |
|
| 53 |
-type errUnauthorized struct{ error }
|
|
| 54 |
- |
|
| 55 |
-func (errUnauthorized) Unauthorized() {}
|
|
| 56 |
- |
|
| 57 |
-func (e errUnauthorized) Cause() error {
|
|
| 58 |
- return e.error |
|
| 59 |
-} |
|
| 60 |
- |
|
| 61 |
-// Unauthorized is a helper to create an error of the class with the same name from any error type |
|
| 62 |
-func Unauthorized(err error) error {
|
|
| 63 |
- if err == nil {
|
|
| 64 |
- return nil |
|
| 65 |
- } |
|
| 66 |
- return errUnauthorized{err}
|
|
| 67 |
-} |
|
| 68 |
- |
|
| 69 |
-type errUnavailable struct{ error }
|
|
| 70 |
- |
|
| 71 |
-func (errUnavailable) Unavailable() {}
|
|
| 72 |
- |
|
| 73 |
-func (e errUnavailable) Cause() error {
|
|
| 74 |
- return e.error |
|
| 75 |
-} |
|
| 76 |
- |
|
| 77 |
-// Unavailable is a helper to create an error of the class with the same name from any error type |
|
| 78 |
-func Unavailable(err error) error {
|
|
| 79 |
- return errUnavailable{err}
|
|
| 80 |
-} |
|
| 81 |
- |
|
| 82 |
-type errForbidden struct{ error }
|
|
| 83 |
- |
|
| 84 |
-func (errForbidden) Forbidden() {}
|
|
| 85 |
- |
|
| 86 |
-func (e errForbidden) Cause() error {
|
|
| 87 |
- return e.error |
|
| 88 |
-} |
|
| 89 |
- |
|
| 90 |
-// Forbidden is a helper to create an error of the class with the same name from any error type |
|
| 91 |
-func Forbidden(err error) error {
|
|
| 92 |
- if err == nil {
|
|
| 93 |
- return nil |
|
| 94 |
- } |
|
| 95 |
- return errForbidden{err}
|
|
| 96 |
-} |
|
| 97 |
- |
|
| 98 |
-type errSystem struct{ error }
|
|
| 99 |
- |
|
| 100 |
-func (errSystem) System() {}
|
|
| 101 |
- |
|
| 102 |
-func (e errSystem) Cause() error {
|
|
| 103 |
- return e.error |
|
| 104 |
-} |
|
| 105 |
- |
|
| 106 |
-// System is a helper to create an error of the class with the same name from any error type |
|
| 107 |
-func System(err error) error {
|
|
| 108 |
- if err == nil {
|
|
| 109 |
- return nil |
|
| 110 |
- } |
|
| 111 |
- return errSystem{err}
|
|
| 112 |
-} |
|
| 113 |
- |
|
| 114 |
-type errNotModified struct{ error }
|
|
| 115 |
- |
|
| 116 |
-func (errNotModified) NotModified() {}
|
|
| 117 |
- |
|
| 118 |
-func (e errNotModified) Cause() error {
|
|
| 119 |
- return e.error |
|
| 120 |
-} |
|
| 121 |
- |
|
| 122 |
-// NotModified is a helper to create an error of the class with the same name from any error type |
|
| 123 |
-func NotModified(err error) error {
|
|
| 124 |
- if err == nil {
|
|
| 125 |
- return nil |
|
| 126 |
- } |
|
| 127 |
- return errNotModified{err}
|
|
| 128 |
-} |
|
| 129 |
- |
|
| 130 |
-type errAlreadyExists struct{ error }
|
|
| 131 |
- |
|
| 132 |
-func (errAlreadyExists) AlreadyExists() {}
|
|
| 133 |
- |
|
| 134 |
-func (e errAlreadyExists) Cause() error {
|
|
| 135 |
- return e.error |
|
| 136 |
-} |
|
| 137 |
- |
|
| 138 |
-// AlreadyExists is a helper to create an error of the class with the same name from any error type |
|
| 139 |
-func AlreadyExists(err error) error {
|
|
| 140 |
- if err == nil {
|
|
| 141 |
- return nil |
|
| 142 |
- } |
|
| 143 |
- return errAlreadyExists{err}
|
|
| 144 |
-} |
|
| 145 |
- |
|
| 146 |
-type errNotImplemented struct{ error }
|
|
| 147 |
- |
|
| 148 |
-func (errNotImplemented) NotImplemented() {}
|
|
| 149 |
- |
|
| 150 |
-func (e errNotImplemented) Cause() error {
|
|
| 151 |
- return e.error |
|
| 152 |
-} |
|
| 153 |
- |
|
| 154 |
-// NotImplemented is a helper to create an error of the class with the same name from any error type |
|
| 155 |
-func NotImplemented(err error) error {
|
|
| 156 |
- if err == nil {
|
|
| 157 |
- return nil |
|
| 158 |
- } |
|
| 159 |
- return errNotImplemented{err}
|
|
| 160 |
-} |
|
| 161 |
- |
|
| 162 |
-type errUnknown struct{ error }
|
|
| 163 |
- |
|
| 164 |
-func (errUnknown) Unknown() {}
|
|
| 165 |
- |
|
| 166 |
-func (e errUnknown) Cause() error {
|
|
| 167 |
- return e.error |
|
| 168 |
-} |
|
| 169 |
- |
|
| 170 |
-// Unknown is a helper to create an error of the class with the same name from any error type |
|
| 171 |
-func Unknown(err error) error {
|
|
| 172 |
- if err == nil {
|
|
| 173 |
- return nil |
|
| 174 |
- } |
|
| 175 |
- return errUnknown{err}
|
|
| 176 |
-} |
|
| 177 |
- |
|
| 178 |
-type errCancelled struct{ error }
|
|
| 179 |
- |
|
| 180 |
-func (errCancelled) Cancelled() {}
|
|
| 181 |
- |
|
| 182 |
-func (e errCancelled) Cause() error {
|
|
| 183 |
- return e.error |
|
| 184 |
-} |
|
| 185 |
- |
|
| 186 |
-// Cancelled is a helper to create an error of the class with the same name from any error type |
|
| 187 |
-func Cancelled(err error) error {
|
|
| 188 |
- if err == nil {
|
|
| 189 |
- return nil |
|
| 190 |
- } |
|
| 191 |
- return errCancelled{err}
|
|
| 192 |
-} |
|
| 193 |
- |
|
| 194 |
-type errDeadline struct{ error }
|
|
| 195 |
- |
|
| 196 |
-func (errDeadline) DeadlineExceeded() {}
|
|
| 197 |
- |
|
| 198 |
-func (e errDeadline) Cause() error {
|
|
| 199 |
- return e.error |
|
| 200 |
-} |
|
| 201 |
- |
|
| 202 |
-// Deadline is a helper to create an error of the class with the same name from any error type |
|
| 203 |
-func Deadline(err error) error {
|
|
| 204 |
- if err == nil {
|
|
| 205 |
- return nil |
|
| 206 |
- } |
|
| 207 |
- return errDeadline{err}
|
|
| 208 |
-} |
|
| 209 |
- |
|
| 210 |
-type errDataLoss struct{ error }
|
|
| 211 |
- |
|
| 212 |
-func (errDataLoss) DataLoss() {}
|
|
| 213 |
- |
|
| 214 |
-func (e errDataLoss) Cause() error {
|
|
| 215 |
- return e.error |
|
| 216 |
-} |
|
| 217 |
- |
|
| 218 |
-// DataLoss is a helper to create an error of the class with the same name from any error type |
|
| 219 |
-func DataLoss(err error) error {
|
|
| 220 |
- if err == nil {
|
|
| 221 |
- return nil |
|
| 222 |
- } |
|
| 223 |
- return errDataLoss{err}
|
|
| 224 |
-} |
|
| 225 |
- |
|
| 226 |
-// FromContext returns the error class from the passed in context |
|
| 227 |
-func FromContext(ctx context.Context) error {
|
|
| 228 |
- e := ctx.Err() |
|
| 229 |
- if e == nil {
|
|
| 230 |
- return nil |
|
| 231 |
- } |
|
| 232 |
- |
|
| 233 |
- if e == context.Canceled {
|
|
| 234 |
- return Cancelled(e) |
|
| 235 |
- } |
|
| 236 |
- if e == context.DeadlineExceeded {
|
|
| 237 |
- return Deadline(e) |
|
| 238 |
- } |
|
| 239 |
- return Unknown(e) |
|
| 240 |
-} |
| 241 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,132 +0,0 @@ |
| 1 |
-package errdefs |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "errors" |
|
| 5 |
- "testing" |
|
| 6 |
-) |
|
| 7 |
- |
|
| 8 |
-var errTest = errors.New("this is a test")
|
|
| 9 |
- |
|
| 10 |
-type causal interface {
|
|
| 11 |
- Cause() error |
|
| 12 |
-} |
|
| 13 |
- |
|
| 14 |
-func TestNotFound(t *testing.T) {
|
|
| 15 |
- e := NotFound(errTest) |
|
| 16 |
- if !IsNotFound(e) {
|
|
| 17 |
- t.Fatalf("expected not found error, got: %T", e)
|
|
| 18 |
- } |
|
| 19 |
- if cause := e.(causal).Cause(); cause != errTest {
|
|
| 20 |
- t.Fatalf("causual should be errTest, got: %v", cause)
|
|
| 21 |
- } |
|
| 22 |
-} |
|
| 23 |
- |
|
| 24 |
-func TestConflict(t *testing.T) {
|
|
| 25 |
- e := Conflict(errTest) |
|
| 26 |
- if !IsConflict(e) {
|
|
| 27 |
- t.Fatalf("expected conflcit error, got: %T", e)
|
|
| 28 |
- } |
|
| 29 |
- if cause := e.(causal).Cause(); cause != errTest {
|
|
| 30 |
- t.Fatalf("causual should be errTest, got: %v", cause)
|
|
| 31 |
- } |
|
| 32 |
-} |
|
| 33 |
- |
|
| 34 |
-func TestForbidden(t *testing.T) {
|
|
| 35 |
- e := Forbidden(errTest) |
|
| 36 |
- if !IsForbidden(e) {
|
|
| 37 |
- t.Fatalf("expected forbidden error, got: %T", e)
|
|
| 38 |
- } |
|
| 39 |
- if cause := e.(causal).Cause(); cause != errTest {
|
|
| 40 |
- t.Fatalf("causual should be errTest, got: %v", cause)
|
|
| 41 |
- } |
|
| 42 |
-} |
|
| 43 |
- |
|
| 44 |
-func TestInvalidParameter(t *testing.T) {
|
|
| 45 |
- e := InvalidParameter(errTest) |
|
| 46 |
- if !IsInvalidParameter(e) {
|
|
| 47 |
- t.Fatalf("expected invalid argument error, got %T", e)
|
|
| 48 |
- } |
|
| 49 |
- if cause := e.(causal).Cause(); cause != errTest {
|
|
| 50 |
- t.Fatalf("causual should be errTest, got: %v", cause)
|
|
| 51 |
- } |
|
| 52 |
-} |
|
| 53 |
- |
|
| 54 |
-func TestNotImplemented(t *testing.T) {
|
|
| 55 |
- e := NotImplemented(errTest) |
|
| 56 |
- if !IsNotImplemented(e) {
|
|
| 57 |
- t.Fatalf("expected not implemented error, got %T", e)
|
|
| 58 |
- } |
|
| 59 |
- if cause := e.(causal).Cause(); cause != errTest {
|
|
| 60 |
- t.Fatalf("causual should be errTest, got: %v", cause)
|
|
| 61 |
- } |
|
| 62 |
-} |
|
| 63 |
- |
|
| 64 |
-func TestNotModified(t *testing.T) {
|
|
| 65 |
- e := NotModified(errTest) |
|
| 66 |
- if !IsNotModified(e) {
|
|
| 67 |
- t.Fatalf("expected not modified error, got %T", e)
|
|
| 68 |
- } |
|
| 69 |
- if cause := e.(causal).Cause(); cause != errTest {
|
|
| 70 |
- t.Fatalf("causual should be errTest, got: %v", cause)
|
|
| 71 |
- } |
|
| 72 |
-} |
|
| 73 |
- |
|
| 74 |
-func TestAlreadyExists(t *testing.T) {
|
|
| 75 |
- e := AlreadyExists(errTest) |
|
| 76 |
- if !IsAlreadyExists(e) {
|
|
| 77 |
- t.Fatalf("expected already exists error, got %T", e)
|
|
| 78 |
- } |
|
| 79 |
- if cause := e.(causal).Cause(); cause != errTest {
|
|
| 80 |
- t.Fatalf("causual should be errTest, got: %v", cause)
|
|
| 81 |
- } |
|
| 82 |
-} |
|
| 83 |
- |
|
| 84 |
-func TestUnauthorized(t *testing.T) {
|
|
| 85 |
- e := Unauthorized(errTest) |
|
| 86 |
- if !IsUnauthorized(e) {
|
|
| 87 |
- t.Fatalf("expected unauthorized error, got %T", e)
|
|
| 88 |
- } |
|
| 89 |
- if cause := e.(causal).Cause(); cause != errTest {
|
|
| 90 |
- t.Fatalf("causual should be errTest, got: %v", cause)
|
|
| 91 |
- } |
|
| 92 |
-} |
|
| 93 |
- |
|
| 94 |
-func TestUnknown(t *testing.T) {
|
|
| 95 |
- e := Unknown(errTest) |
|
| 96 |
- if !IsUnknown(e) {
|
|
| 97 |
- t.Fatalf("expected unknown error, got %T", e)
|
|
| 98 |
- } |
|
| 99 |
- if cause := e.(causal).Cause(); cause != errTest {
|
|
| 100 |
- t.Fatalf("causual should be errTest, got: %v", cause)
|
|
| 101 |
- } |
|
| 102 |
-} |
|
| 103 |
- |
|
| 104 |
-func TestCancelled(t *testing.T) {
|
|
| 105 |
- e := Cancelled(errTest) |
|
| 106 |
- if !IsCancelled(e) {
|
|
| 107 |
- t.Fatalf("expected canclled error, got %T", e)
|
|
| 108 |
- } |
|
| 109 |
- if cause := e.(causal).Cause(); cause != errTest {
|
|
| 110 |
- t.Fatalf("causual should be errTest, got: %v", cause)
|
|
| 111 |
- } |
|
| 112 |
-} |
|
| 113 |
- |
|
| 114 |
-func TestDeadline(t *testing.T) {
|
|
| 115 |
- e := Deadline(errTest) |
|
| 116 |
- if !IsDeadline(e) {
|
|
| 117 |
- t.Fatalf("expected deadline error, got %T", e)
|
|
| 118 |
- } |
|
| 119 |
- if cause := e.(causal).Cause(); cause != errTest {
|
|
| 120 |
- t.Fatalf("causual should be errTest, got: %v", cause)
|
|
| 121 |
- } |
|
| 122 |
-} |
|
| 123 |
- |
|
| 124 |
-func TestIsDataLoss(t *testing.T) {
|
|
| 125 |
- e := DataLoss(errTest) |
|
| 126 |
- if !IsDataLoss(e) {
|
|
| 127 |
- t.Fatalf("expected data loss error, got %T", e)
|
|
| 128 |
- } |
|
| 129 |
- if cause := e.(causal).Cause(); cause != errTest {
|
|
| 130 |
- t.Fatalf("causual should be errTest, got: %v", cause)
|
|
| 131 |
- } |
|
| 132 |
-} |
| 133 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,114 +0,0 @@ |
| 1 |
-package errdefs |
|
| 2 |
- |
|
| 3 |
-type causer interface {
|
|
| 4 |
- Cause() error |
|
| 5 |
-} |
|
| 6 |
- |
|
| 7 |
-func getImplementer(err error) error {
|
|
| 8 |
- switch e := err.(type) {
|
|
| 9 |
- case |
|
| 10 |
- ErrNotFound, |
|
| 11 |
- ErrInvalidParameter, |
|
| 12 |
- ErrConflict, |
|
| 13 |
- ErrUnauthorized, |
|
| 14 |
- ErrUnavailable, |
|
| 15 |
- ErrForbidden, |
|
| 16 |
- ErrSystem, |
|
| 17 |
- ErrNotModified, |
|
| 18 |
- ErrAlreadyExists, |
|
| 19 |
- ErrNotImplemented, |
|
| 20 |
- ErrCancelled, |
|
| 21 |
- ErrDeadline, |
|
| 22 |
- ErrDataLoss, |
|
| 23 |
- ErrUnknown: |
|
| 24 |
- return e |
|
| 25 |
- case causer: |
|
| 26 |
- return getImplementer(e.Cause()) |
|
| 27 |
- default: |
|
| 28 |
- return err |
|
| 29 |
- } |
|
| 30 |
-} |
|
| 31 |
- |
|
| 32 |
-// IsNotFound returns if the passed in error is an ErrNotFound |
|
| 33 |
-func IsNotFound(err error) bool {
|
|
| 34 |
- _, ok := getImplementer(err).(ErrNotFound) |
|
| 35 |
- return ok |
|
| 36 |
-} |
|
| 37 |
- |
|
| 38 |
-// IsInvalidParameter returns if the passed in error is an ErrInvalidParameter |
|
| 39 |
-func IsInvalidParameter(err error) bool {
|
|
| 40 |
- _, ok := getImplementer(err).(ErrInvalidParameter) |
|
| 41 |
- return ok |
|
| 42 |
-} |
|
| 43 |
- |
|
| 44 |
-// IsConflict returns if the passed in error is an ErrConflict |
|
| 45 |
-func IsConflict(err error) bool {
|
|
| 46 |
- _, ok := getImplementer(err).(ErrConflict) |
|
| 47 |
- return ok |
|
| 48 |
-} |
|
| 49 |
- |
|
| 50 |
-// IsUnauthorized returns if the the passed in error is an ErrUnauthorized |
|
| 51 |
-func IsUnauthorized(err error) bool {
|
|
| 52 |
- _, ok := getImplementer(err).(ErrUnauthorized) |
|
| 53 |
- return ok |
|
| 54 |
-} |
|
| 55 |
- |
|
| 56 |
-// IsUnavailable returns if the passed in error is an ErrUnavailable |
|
| 57 |
-func IsUnavailable(err error) bool {
|
|
| 58 |
- _, ok := getImplementer(err).(ErrUnavailable) |
|
| 59 |
- return ok |
|
| 60 |
-} |
|
| 61 |
- |
|
| 62 |
-// IsForbidden returns if the passed in error is an ErrForbidden |
|
| 63 |
-func IsForbidden(err error) bool {
|
|
| 64 |
- _, ok := getImplementer(err).(ErrForbidden) |
|
| 65 |
- return ok |
|
| 66 |
-} |
|
| 67 |
- |
|
| 68 |
-// IsSystem returns if the passed in error is an ErrSystem |
|
| 69 |
-func IsSystem(err error) bool {
|
|
| 70 |
- _, ok := getImplementer(err).(ErrSystem) |
|
| 71 |
- return ok |
|
| 72 |
-} |
|
| 73 |
- |
|
| 74 |
-// IsNotModified returns if the passed in error is a NotModified error |
|
| 75 |
-func IsNotModified(err error) bool {
|
|
| 76 |
- _, ok := getImplementer(err).(ErrNotModified) |
|
| 77 |
- return ok |
|
| 78 |
-} |
|
| 79 |
- |
|
| 80 |
-// IsAlreadyExists returns if the passed in error is a AlreadyExists error |
|
| 81 |
-func IsAlreadyExists(err error) bool {
|
|
| 82 |
- _, ok := getImplementer(err).(ErrAlreadyExists) |
|
| 83 |
- return ok |
|
| 84 |
-} |
|
| 85 |
- |
|
| 86 |
-// IsNotImplemented returns if the passed in error is an ErrNotImplemented |
|
| 87 |
-func IsNotImplemented(err error) bool {
|
|
| 88 |
- _, ok := getImplementer(err).(ErrNotImplemented) |
|
| 89 |
- return ok |
|
| 90 |
-} |
|
| 91 |
- |
|
| 92 |
-// IsUnknown returns if the passed in error is an ErrUnknown |
|
| 93 |
-func IsUnknown(err error) bool {
|
|
| 94 |
- _, ok := getImplementer(err).(ErrUnknown) |
|
| 95 |
- return ok |
|
| 96 |
-} |
|
| 97 |
- |
|
| 98 |
-// IsCancelled returns if the passed in error is an ErrCancelled |
|
| 99 |
-func IsCancelled(err error) bool {
|
|
| 100 |
- _, ok := getImplementer(err).(ErrCancelled) |
|
| 101 |
- return ok |
|
| 102 |
-} |
|
| 103 |
- |
|
| 104 |
-// IsDeadline returns if the passed in error is an ErrDeadline |
|
| 105 |
-func IsDeadline(err error) bool {
|
|
| 106 |
- _, ok := getImplementer(err).(ErrDeadline) |
|
| 107 |
- return ok |
|
| 108 |
-} |
|
| 109 |
- |
|
| 110 |
-// IsDataLoss returns if the passed in error is an ErrDataLoss |
|
| 111 |
-func IsDataLoss(err error) bool {
|
|
| 112 |
- _, ok := getImplementer(err).(ErrDataLoss) |
|
| 113 |
- return ok |
|
| 114 |
-} |
| ... | ... |
@@ -4,9 +4,9 @@ import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"net/http" |
| 6 | 6 |
|
| 7 |
- "github.com/docker/docker/api/errdefs" |
|
| 8 | 7 |
"github.com/docker/docker/api/types" |
| 9 | 8 |
"github.com/docker/docker/api/types/versions" |
| 9 |
+ "github.com/docker/docker/errdefs" |
|
| 10 | 10 |
"github.com/gorilla/mux" |
| 11 | 11 |
"github.com/sirupsen/logrus" |
| 12 | 12 |
"google.golang.org/grpc" |
| ... | ... |
@@ -13,12 +13,12 @@ import ( |
| 13 | 13 |
"strings" |
| 14 | 14 |
"sync" |
| 15 | 15 |
|
| 16 |
- "github.com/docker/docker/api/errdefs" |
|
| 17 | 16 |
"github.com/docker/docker/api/server/httputils" |
| 18 | 17 |
"github.com/docker/docker/api/types" |
| 19 | 18 |
"github.com/docker/docker/api/types/backend" |
| 20 | 19 |
"github.com/docker/docker/api/types/container" |
| 21 | 20 |
"github.com/docker/docker/api/types/versions" |
| 21 |
+ "github.com/docker/docker/errdefs" |
|
| 22 | 22 |
"github.com/docker/docker/pkg/ioutils" |
| 23 | 23 |
"github.com/docker/docker/pkg/progress" |
| 24 | 24 |
"github.com/docker/docker/pkg/streamformatter" |
| ... | ... |
@@ -8,7 +8,6 @@ import ( |
| 8 | 8 |
"strconv" |
| 9 | 9 |
"syscall" |
| 10 | 10 |
|
| 11 |
- "github.com/docker/docker/api/errdefs" |
|
| 12 | 11 |
"github.com/docker/docker/api/server/httputils" |
| 13 | 12 |
"github.com/docker/docker/api/types" |
| 14 | 13 |
"github.com/docker/docker/api/types/backend" |
| ... | ... |
@@ -16,6 +15,7 @@ import ( |
| 16 | 16 |
"github.com/docker/docker/api/types/filters" |
| 17 | 17 |
"github.com/docker/docker/api/types/versions" |
| 18 | 18 |
containerpkg "github.com/docker/docker/container" |
| 19 |
+ "github.com/docker/docker/errdefs" |
|
| 19 | 20 |
"github.com/docker/docker/pkg/ioutils" |
| 20 | 21 |
"github.com/docker/docker/pkg/signal" |
| 21 | 22 |
"github.com/pkg/errors" |
| ... | ... |
@@ -7,10 +7,10 @@ import ( |
| 7 | 7 |
"net/http" |
| 8 | 8 |
"strconv" |
| 9 | 9 |
|
| 10 |
- "github.com/docker/docker/api/errdefs" |
|
| 11 | 10 |
"github.com/docker/docker/api/server/httputils" |
| 12 | 11 |
"github.com/docker/docker/api/types" |
| 13 | 12 |
"github.com/docker/docker/api/types/versions" |
| 13 |
+ "github.com/docker/docker/errdefs" |
|
| 14 | 14 |
"github.com/docker/docker/pkg/stdcopy" |
| 15 | 15 |
"github.com/sirupsen/logrus" |
| 16 | 16 |
"golang.org/x/net/context" |
| ... | ... |
@@ -10,12 +10,12 @@ import ( |
| 10 | 10 |
"strconv" |
| 11 | 11 |
"strings" |
| 12 | 12 |
|
| 13 |
- "github.com/docker/docker/api/errdefs" |
|
| 14 | 13 |
"github.com/docker/docker/api/server/httputils" |
| 15 | 14 |
"github.com/docker/docker/api/types" |
| 16 | 15 |
"github.com/docker/docker/api/types/backend" |
| 17 | 16 |
"github.com/docker/docker/api/types/filters" |
| 18 | 17 |
"github.com/docker/docker/api/types/versions" |
| 18 |
+ "github.com/docker/docker/errdefs" |
|
| 19 | 19 |
"github.com/docker/docker/pkg/ioutils" |
| 20 | 20 |
"github.com/docker/docker/pkg/streamformatter" |
| 21 | 21 |
"github.com/docker/docker/pkg/system" |
| ... | ... |
@@ -8,12 +8,12 @@ import ( |
| 8 | 8 |
|
| 9 | 9 |
"golang.org/x/net/context" |
| 10 | 10 |
|
| 11 |
- "github.com/docker/docker/api/errdefs" |
|
| 12 | 11 |
"github.com/docker/docker/api/server/httputils" |
| 13 | 12 |
"github.com/docker/docker/api/types" |
| 14 | 13 |
"github.com/docker/docker/api/types/filters" |
| 15 | 14 |
"github.com/docker/docker/api/types/network" |
| 16 | 15 |
"github.com/docker/docker/api/types/versions" |
| 16 |
+ "github.com/docker/docker/errdefs" |
|
| 17 | 17 |
"github.com/docker/libnetwork" |
| 18 | 18 |
netconst "github.com/docker/libnetwork/datastore" |
| 19 | 19 |
"github.com/docker/libnetwork/networkdb" |
| ... | ... |
@@ -6,13 +6,13 @@ import ( |
| 6 | 6 |
"net/http" |
| 7 | 7 |
"strconv" |
| 8 | 8 |
|
| 9 |
- "github.com/docker/docker/api/errdefs" |
|
| 10 | 9 |
"github.com/docker/docker/api/server/httputils" |
| 11 | 10 |
basictypes "github.com/docker/docker/api/types" |
| 12 | 11 |
"github.com/docker/docker/api/types/backend" |
| 13 | 12 |
"github.com/docker/docker/api/types/filters" |
| 14 | 13 |
types "github.com/docker/docker/api/types/swarm" |
| 15 | 14 |
"github.com/docker/docker/api/types/versions" |
| 15 |
+ "github.com/docker/docker/errdefs" |
|
| 16 | 16 |
"github.com/pkg/errors" |
| 17 | 17 |
"github.com/sirupsen/logrus" |
| 18 | 18 |
"golang.org/x/net/context" |
| ... | ... |
@@ -9,7 +9,6 @@ import ( |
| 9 | 9 |
"strings" |
| 10 | 10 |
"time" |
| 11 | 11 |
|
| 12 |
- "github.com/docker/docker/api/errdefs" |
|
| 13 | 12 |
"github.com/docker/docker/api/types" |
| 14 | 13 |
"github.com/docker/docker/api/types/backend" |
| 15 | 14 |
"github.com/docker/docker/api/types/container" |
| ... | ... |
@@ -18,6 +17,7 @@ import ( |
| 18 | 18 |
"github.com/docker/docker/builder/dockerfile/parser" |
| 19 | 19 |
"github.com/docker/docker/builder/fscache" |
| 20 | 20 |
"github.com/docker/docker/builder/remotecontext" |
| 21 |
+ "github.com/docker/docker/errdefs" |
|
| 21 | 22 |
"github.com/docker/docker/pkg/idtools" |
| 22 | 23 |
"github.com/docker/docker/pkg/streamformatter" |
| 23 | 24 |
"github.com/docker/docker/pkg/stringid" |
| ... | ... |
@@ -15,12 +15,12 @@ import ( |
| 15 | 15 |
"strings" |
| 16 | 16 |
|
| 17 | 17 |
"github.com/docker/docker/api" |
| 18 |
- "github.com/docker/docker/api/errdefs" |
|
| 19 | 18 |
"github.com/docker/docker/api/types/container" |
| 20 | 19 |
"github.com/docker/docker/api/types/strslice" |
| 21 | 20 |
"github.com/docker/docker/builder" |
| 22 | 21 |
"github.com/docker/docker/builder/dockerfile/instructions" |
| 23 | 22 |
"github.com/docker/docker/builder/dockerfile/parser" |
| 23 |
+ "github.com/docker/docker/errdefs" |
|
| 24 | 24 |
"github.com/docker/docker/image" |
| 25 | 25 |
"github.com/docker/docker/pkg/jsonmessage" |
| 26 | 26 |
"github.com/docker/docker/pkg/signal" |
| ... | ... |
@@ -24,10 +24,10 @@ import ( |
| 24 | 24 |
"strconv" |
| 25 | 25 |
"strings" |
| 26 | 26 |
|
| 27 |
- "github.com/docker/docker/api/errdefs" |
|
| 28 | 27 |
"github.com/docker/docker/api/types/container" |
| 29 | 28 |
"github.com/docker/docker/builder" |
| 30 | 29 |
"github.com/docker/docker/builder/dockerfile/instructions" |
| 30 |
+ "github.com/docker/docker/errdefs" |
|
| 31 | 31 |
"github.com/docker/docker/pkg/system" |
| 32 | 32 |
"github.com/docker/docker/runconfig/opts" |
| 33 | 33 |
"github.com/pkg/errors" |
| ... | ... |
@@ -5,9 +5,9 @@ import ( |
| 5 | 5 |
"os" |
| 6 | 6 |
"strings" |
| 7 | 7 |
|
| 8 |
- "github.com/docker/docker/api/errdefs" |
|
| 9 | 8 |
"github.com/docker/docker/api/types" |
| 10 | 9 |
"github.com/docker/docker/container" |
| 10 |
+ "github.com/docker/docker/errdefs" |
|
| 11 | 11 |
"github.com/docker/docker/pkg/archive" |
| 12 | 12 |
"github.com/docker/docker/pkg/chrootarchive" |
| 13 | 13 |
"github.com/docker/docker/pkg/ioutils" |
| ... | ... |
@@ -5,11 +5,11 @@ import ( |
| 5 | 5 |
"fmt" |
| 6 | 6 |
"io" |
| 7 | 7 |
|
| 8 |
- "github.com/docker/docker/api/errdefs" |
|
| 9 | 8 |
"github.com/docker/docker/api/types/backend" |
| 10 | 9 |
"github.com/docker/docker/container" |
| 11 | 10 |
"github.com/docker/docker/container/stream" |
| 12 | 11 |
"github.com/docker/docker/daemon/logger" |
| 12 |
+ "github.com/docker/docker/errdefs" |
|
| 13 | 13 |
"github.com/docker/docker/pkg/stdcopy" |
| 14 | 14 |
"github.com/docker/docker/pkg/term" |
| 15 | 15 |
"github.com/pkg/errors" |
| ... | ... |
@@ -6,9 +6,9 @@ import ( |
| 6 | 6 |
"net/http" |
| 7 | 7 |
|
| 8 | 8 |
"github.com/docker/distribution/reference" |
| 9 |
- "github.com/docker/docker/api/errdefs" |
|
| 10 | 9 |
enginetypes "github.com/docker/docker/api/types" |
| 11 | 10 |
"github.com/docker/docker/api/types/swarm/runtime" |
| 11 |
+ "github.com/docker/docker/errdefs" |
|
| 12 | 12 |
"github.com/docker/docker/plugin" |
| 13 | 13 |
"github.com/docker/docker/plugin/v2" |
| 14 | 14 |
"github.com/docker/swarmkit/api" |
| ... | ... |
@@ -3,11 +3,11 @@ package cluster |
| 3 | 3 |
import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
|
| 6 |
- "github.com/docker/docker/api/errdefs" |
|
| 7 | 6 |
apitypes "github.com/docker/docker/api/types" |
| 8 | 7 |
"github.com/docker/docker/api/types/network" |
| 9 | 8 |
types "github.com/docker/docker/api/types/swarm" |
| 10 | 9 |
"github.com/docker/docker/daemon/cluster/convert" |
| 10 |
+ "github.com/docker/docker/errdefs" |
|
| 11 | 11 |
"github.com/docker/docker/runconfig" |
| 12 | 12 |
swarmapi "github.com/docker/swarmkit/api" |
| 13 | 13 |
"github.com/pkg/errors" |
| ... | ... |
@@ -1,10 +1,10 @@ |
| 1 | 1 |
package cluster |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "github.com/docker/docker/api/errdefs" |
|
| 5 | 4 |
apitypes "github.com/docker/docker/api/types" |
| 6 | 5 |
types "github.com/docker/docker/api/types/swarm" |
| 7 | 6 |
"github.com/docker/docker/daemon/cluster/convert" |
| 7 |
+ "github.com/docker/docker/errdefs" |
|
| 8 | 8 |
swarmapi "github.com/docker/swarmkit/api" |
| 9 | 9 |
"golang.org/x/net/context" |
| 10 | 10 |
) |
| ... | ... |
@@ -11,12 +11,12 @@ import ( |
| 11 | 11 |
"time" |
| 12 | 12 |
|
| 13 | 13 |
"github.com/docker/distribution/reference" |
| 14 |
- "github.com/docker/docker/api/errdefs" |
|
| 15 | 14 |
apitypes "github.com/docker/docker/api/types" |
| 16 | 15 |
"github.com/docker/docker/api/types/backend" |
| 17 | 16 |
types "github.com/docker/docker/api/types/swarm" |
| 18 | 17 |
timetypes "github.com/docker/docker/api/types/time" |
| 19 | 18 |
"github.com/docker/docker/daemon/cluster/convert" |
| 19 |
+ "github.com/docker/docker/errdefs" |
|
| 20 | 20 |
runconfigopts "github.com/docker/docker/runconfig/opts" |
| 21 | 21 |
swarmapi "github.com/docker/swarmkit/api" |
| 22 | 22 |
gogotypes "github.com/gogo/protobuf/types" |
| ... | ... |
@@ -6,11 +6,11 @@ import ( |
| 6 | 6 |
"strings" |
| 7 | 7 |
"time" |
| 8 | 8 |
|
| 9 |
- "github.com/docker/docker/api/errdefs" |
|
| 10 | 9 |
apitypes "github.com/docker/docker/api/types" |
| 11 | 10 |
"github.com/docker/docker/api/types/filters" |
| 12 | 11 |
types "github.com/docker/docker/api/types/swarm" |
| 13 | 12 |
"github.com/docker/docker/daemon/cluster/convert" |
| 13 |
+ "github.com/docker/docker/errdefs" |
|
| 14 | 14 |
"github.com/docker/docker/opts" |
| 15 | 15 |
"github.com/docker/docker/pkg/signal" |
| 16 | 16 |
swarmapi "github.com/docker/swarmkit/api" |
| ... | ... |
@@ -9,11 +9,11 @@ import ( |
| 9 | 9 |
"time" |
| 10 | 10 |
|
| 11 | 11 |
"github.com/docker/distribution/reference" |
| 12 |
- "github.com/docker/docker/api/errdefs" |
|
| 13 | 12 |
"github.com/docker/docker/api/types/backend" |
| 14 | 13 |
containertypes "github.com/docker/docker/api/types/container" |
| 15 | 14 |
"github.com/docker/docker/builder/dockerfile" |
| 16 | 15 |
"github.com/docker/docker/container" |
| 16 |
+ "github.com/docker/docker/errdefs" |
|
| 17 | 17 |
"github.com/docker/docker/image" |
| 18 | 18 |
"github.com/docker/docker/layer" |
| 19 | 19 |
"github.com/docker/docker/pkg/ioutils" |
| ... | ... |
@@ -9,11 +9,11 @@ import ( |
| 9 | 9 |
"strings" |
| 10 | 10 |
"time" |
| 11 | 11 |
|
| 12 |
- "github.com/docker/docker/api/errdefs" |
|
| 13 | 12 |
containertypes "github.com/docker/docker/api/types/container" |
| 14 | 13 |
"github.com/docker/docker/api/types/strslice" |
| 15 | 14 |
"github.com/docker/docker/container" |
| 16 | 15 |
"github.com/docker/docker/daemon/network" |
| 16 |
+ "github.com/docker/docker/errdefs" |
|
| 17 | 17 |
"github.com/docker/docker/image" |
| 18 | 18 |
"github.com/docker/docker/opts" |
| 19 | 19 |
"github.com/docker/docker/pkg/signal" |
| ... | ... |
@@ -10,11 +10,11 @@ import ( |
| 10 | 10 |
"strings" |
| 11 | 11 |
"time" |
| 12 | 12 |
|
| 13 |
- "github.com/docker/docker/api/errdefs" |
|
| 14 | 13 |
containertypes "github.com/docker/docker/api/types/container" |
| 15 | 14 |
networktypes "github.com/docker/docker/api/types/network" |
| 16 | 15 |
"github.com/docker/docker/container" |
| 17 | 16 |
"github.com/docker/docker/daemon/network" |
| 17 |
+ "github.com/docker/docker/errdefs" |
|
| 18 | 18 |
"github.com/docker/docker/opts" |
| 19 | 19 |
"github.com/docker/docker/pkg/stringid" |
| 20 | 20 |
"github.com/docker/docker/runconfig" |
| ... | ... |
@@ -11,9 +11,9 @@ import ( |
| 11 | 11 |
"strconv" |
| 12 | 12 |
"time" |
| 13 | 13 |
|
| 14 |
- "github.com/docker/docker/api/errdefs" |
|
| 15 | 14 |
"github.com/docker/docker/container" |
| 16 | 15 |
"github.com/docker/docker/daemon/links" |
| 16 |
+ "github.com/docker/docker/errdefs" |
|
| 17 | 17 |
"github.com/docker/docker/pkg/idtools" |
| 18 | 18 |
"github.com/docker/docker/pkg/mount" |
| 19 | 19 |
"github.com/docker/docker/pkg/stringid" |
| ... | ... |
@@ -9,11 +9,11 @@ import ( |
| 9 | 9 |
|
| 10 | 10 |
"github.com/pkg/errors" |
| 11 | 11 |
|
| 12 |
- "github.com/docker/docker/api/errdefs" |
|
| 13 | 12 |
"github.com/docker/docker/api/types" |
| 14 | 13 |
containertypes "github.com/docker/docker/api/types/container" |
| 15 | 14 |
networktypes "github.com/docker/docker/api/types/network" |
| 16 | 15 |
"github.com/docker/docker/container" |
| 16 |
+ "github.com/docker/docker/errdefs" |
|
| 17 | 17 |
"github.com/docker/docker/image" |
| 18 | 18 |
"github.com/docker/docker/layer" |
| 19 | 19 |
"github.com/docker/docker/pkg/idtools" |
| ... | ... |
@@ -18,7 +18,6 @@ import ( |
| 18 | 18 |
"sync" |
| 19 | 19 |
"time" |
| 20 | 20 |
|
| 21 |
- "github.com/docker/docker/api/errdefs" |
|
| 22 | 21 |
"github.com/docker/docker/api/types" |
| 23 | 22 |
containertypes "github.com/docker/docker/api/types/container" |
| 24 | 23 |
"github.com/docker/docker/api/types/swarm" |
| ... | ... |
@@ -29,6 +28,7 @@ import ( |
| 29 | 29 |
"github.com/docker/docker/daemon/exec" |
| 30 | 30 |
"github.com/docker/docker/daemon/logger" |
| 31 | 31 |
"github.com/docker/docker/daemon/network" |
| 32 |
+ "github.com/docker/docker/errdefs" |
|
| 32 | 33 |
"github.com/sirupsen/logrus" |
| 33 | 34 |
// register graph drivers |
| 34 | 35 |
_ "github.com/docker/docker/daemon/graphdriver/register" |
| ... | ... |
@@ -7,9 +7,9 @@ import ( |
| 7 | 7 |
"runtime" |
| 8 | 8 |
"testing" |
| 9 | 9 |
|
| 10 |
- "github.com/docker/docker/api/errdefs" |
|
| 11 | 10 |
containertypes "github.com/docker/docker/api/types/container" |
| 12 | 11 |
"github.com/docker/docker/container" |
| 12 |
+ "github.com/docker/docker/errdefs" |
|
| 13 | 13 |
_ "github.com/docker/docker/pkg/discovery/memory" |
| 14 | 14 |
"github.com/docker/docker/pkg/idtools" |
| 15 | 15 |
"github.com/docker/docker/pkg/truncindex" |
| ... | ... |
@@ -7,9 +7,9 @@ import ( |
| 7 | 7 |
"strings" |
| 8 | 8 |
"time" |
| 9 | 9 |
|
| 10 |
- "github.com/docker/docker/api/errdefs" |
|
| 11 | 10 |
"github.com/docker/docker/api/types" |
| 12 | 11 |
"github.com/docker/docker/container" |
| 12 |
+ "github.com/docker/docker/errdefs" |
|
| 13 | 13 |
"github.com/docker/docker/layer" |
| 14 | 14 |
"github.com/docker/docker/pkg/system" |
| 15 | 15 |
"github.com/docker/docker/volume" |
| ... | ... |
@@ -8,12 +8,12 @@ import ( |
| 8 | 8 |
|
| 9 | 9 |
"golang.org/x/net/context" |
| 10 | 10 |
|
| 11 |
- "github.com/docker/docker/api/errdefs" |
|
| 12 | 11 |
"github.com/docker/docker/api/types" |
| 13 | 12 |
"github.com/docker/docker/api/types/strslice" |
| 14 | 13 |
"github.com/docker/docker/container" |
| 15 | 14 |
"github.com/docker/docker/container/stream" |
| 16 | 15 |
"github.com/docker/docker/daemon/exec" |
| 16 |
+ "github.com/docker/docker/errdefs" |
|
| 17 | 17 |
"github.com/docker/docker/pkg/pools" |
| 18 | 18 |
"github.com/docker/docker/pkg/signal" |
| 19 | 19 |
"github.com/docker/docker/pkg/term" |
| ... | ... |
@@ -6,9 +6,9 @@ import ( |
| 6 | 6 |
"time" |
| 7 | 7 |
|
| 8 | 8 |
"github.com/docker/distribution/reference" |
| 9 |
- "github.com/docker/docker/api/errdefs" |
|
| 10 | 9 |
"github.com/docker/docker/api/types" |
| 11 | 10 |
"github.com/docker/docker/container" |
| 11 |
+ "github.com/docker/docker/errdefs" |
|
| 12 | 12 |
"github.com/docker/docker/image" |
| 13 | 13 |
"github.com/docker/docker/pkg/stringid" |
| 14 | 14 |
"github.com/pkg/errors" |
| ... | ... |
@@ -7,10 +7,10 @@ import ( |
| 7 | 7 |
|
| 8 | 8 |
dist "github.com/docker/distribution" |
| 9 | 9 |
"github.com/docker/distribution/reference" |
| 10 |
- "github.com/docker/docker/api/errdefs" |
|
| 11 | 10 |
"github.com/docker/docker/api/types" |
| 12 | 11 |
"github.com/docker/docker/distribution" |
| 13 | 12 |
progressutils "github.com/docker/docker/distribution/utils" |
| 13 |
+ "github.com/docker/docker/errdefs" |
|
| 14 | 14 |
"github.com/docker/docker/pkg/progress" |
| 15 | 15 |
"github.com/docker/docker/registry" |
| 16 | 16 |
"github.com/opencontainers/go-digest" |
| ... | ... |
@@ -10,11 +10,11 @@ import ( |
| 10 | 10 |
"time" |
| 11 | 11 |
|
| 12 | 12 |
"github.com/docker/distribution/reference" |
| 13 |
- "github.com/docker/docker/api/errdefs" |
|
| 14 | 13 |
"github.com/docker/docker/api/types/container" |
| 15 | 14 |
"github.com/docker/docker/builder/dockerfile" |
| 16 | 15 |
"github.com/docker/docker/builder/remotecontext" |
| 17 | 16 |
"github.com/docker/docker/dockerversion" |
| 17 |
+ "github.com/docker/docker/errdefs" |
|
| 18 | 18 |
"github.com/docker/docker/image" |
| 19 | 19 |
"github.com/docker/docker/layer" |
| 20 | 20 |
"github.com/docker/docker/pkg/archive" |
| ... | ... |
@@ -4,7 +4,6 @@ import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"time" |
| 6 | 6 |
|
| 7 |
- "github.com/docker/docker/api/errdefs" |
|
| 8 | 7 |
"github.com/docker/docker/api/types" |
| 9 | 8 |
"github.com/docker/docker/api/types/backend" |
| 10 | 9 |
networktypes "github.com/docker/docker/api/types/network" |
| ... | ... |
@@ -12,6 +11,7 @@ import ( |
| 12 | 12 |
"github.com/docker/docker/api/types/versions/v1p20" |
| 13 | 13 |
"github.com/docker/docker/container" |
| 14 | 14 |
"github.com/docker/docker/daemon/network" |
| 15 |
+ "github.com/docker/docker/errdefs" |
|
| 15 | 16 |
volumestore "github.com/docker/docker/volume/store" |
| 16 | 17 |
"github.com/docker/go-connections/nat" |
| 17 | 18 |
) |
| ... | ... |
@@ -7,8 +7,8 @@ import ( |
| 7 | 7 |
"syscall" |
| 8 | 8 |
"time" |
| 9 | 9 |
|
| 10 |
- "github.com/docker/docker/api/errdefs" |
|
| 11 | 10 |
containerpkg "github.com/docker/docker/container" |
| 11 |
+ "github.com/docker/docker/errdefs" |
|
| 12 | 12 |
"github.com/docker/docker/libcontainerd" |
| 13 | 13 |
"github.com/docker/docker/pkg/signal" |
| 14 | 14 |
"github.com/pkg/errors" |
| ... | ... |
@@ -6,10 +6,10 @@ import ( |
| 6 | 6 |
"strconv" |
| 7 | 7 |
"strings" |
| 8 | 8 |
|
| 9 |
- "github.com/docker/docker/api/errdefs" |
|
| 10 | 9 |
"github.com/docker/docker/api/types" |
| 11 | 10 |
"github.com/docker/docker/api/types/filters" |
| 12 | 11 |
"github.com/docker/docker/container" |
| 12 |
+ "github.com/docker/docker/errdefs" |
|
| 13 | 13 |
"github.com/docker/docker/image" |
| 14 | 14 |
"github.com/docker/docker/volume" |
| 15 | 15 |
"github.com/docker/go-connections/nat" |
| ... | ... |
@@ -7,13 +7,13 @@ import ( |
| 7 | 7 |
|
| 8 | 8 |
"golang.org/x/net/context" |
| 9 | 9 |
|
| 10 |
- "github.com/docker/docker/api/errdefs" |
|
| 11 | 10 |
"github.com/docker/docker/api/types" |
| 12 | 11 |
"github.com/docker/docker/api/types/backend" |
| 13 | 12 |
containertypes "github.com/docker/docker/api/types/container" |
| 14 | 13 |
timetypes "github.com/docker/docker/api/types/time" |
| 15 | 14 |
"github.com/docker/docker/container" |
| 16 | 15 |
"github.com/docker/docker/daemon/logger" |
| 16 |
+ "github.com/docker/docker/errdefs" |
|
| 17 | 17 |
"github.com/sirupsen/logrus" |
| 18 | 18 |
) |
| 19 | 19 |
|
| ... | ... |
@@ -4,9 +4,9 @@ import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"strings" |
| 6 | 6 |
|
| 7 |
- "github.com/docker/docker/api/errdefs" |
|
| 8 | 7 |
"github.com/docker/docker/container" |
| 9 | 8 |
"github.com/docker/docker/daemon/names" |
| 9 |
+ "github.com/docker/docker/errdefs" |
|
| 10 | 10 |
"github.com/docker/docker/pkg/namesgenerator" |
| 11 | 11 |
"github.com/docker/docker/pkg/stringid" |
| 12 | 12 |
"github.com/pkg/errors" |
| ... | ... |
@@ -8,10 +8,10 @@ import ( |
| 8 | 8 |
"strings" |
| 9 | 9 |
"sync" |
| 10 | 10 |
|
| 11 |
- "github.com/docker/docker/api/errdefs" |
|
| 12 | 11 |
"github.com/docker/docker/api/types" |
| 13 | 12 |
"github.com/docker/docker/api/types/network" |
| 14 | 13 |
clustertypes "github.com/docker/docker/daemon/cluster/provider" |
| 14 |
+ "github.com/docker/docker/errdefs" |
|
| 15 | 15 |
"github.com/docker/docker/pkg/plugingetter" |
| 16 | 16 |
"github.com/docker/docker/runconfig" |
| 17 | 17 |
"github.com/docker/libnetwork" |
| ... | ... |
@@ -3,8 +3,8 @@ package daemon |
| 3 | 3 |
import ( |
| 4 | 4 |
"strings" |
| 5 | 5 |
|
| 6 |
- "github.com/docker/docker/api/errdefs" |
|
| 7 | 6 |
dockercontainer "github.com/docker/docker/container" |
| 7 |
+ "github.com/docker/docker/errdefs" |
|
| 8 | 8 |
"github.com/docker/libnetwork" |
| 9 | 9 |
"github.com/pkg/errors" |
| 10 | 10 |
"github.com/sirupsen/logrus" |
| ... | ... |
@@ -5,10 +5,10 @@ import ( |
| 5 | 5 |
"runtime" |
| 6 | 6 |
"time" |
| 7 | 7 |
|
| 8 |
- "github.com/docker/docker/api/errdefs" |
|
| 9 | 8 |
"github.com/docker/docker/api/types" |
| 10 | 9 |
containertypes "github.com/docker/docker/api/types/container" |
| 11 | 10 |
"github.com/docker/docker/container" |
| 11 |
+ "github.com/docker/docker/errdefs" |
|
| 12 | 12 |
"github.com/pkg/errors" |
| 13 | 13 |
"github.com/sirupsen/logrus" |
| 14 | 14 |
) |
| ... | ... |
@@ -8,11 +8,11 @@ import ( |
| 8 | 8 |
"strings" |
| 9 | 9 |
"time" |
| 10 | 10 |
|
| 11 |
- "github.com/docker/docker/api/errdefs" |
|
| 12 | 11 |
"github.com/docker/docker/api/types" |
| 13 | 12 |
containertypes "github.com/docker/docker/api/types/container" |
| 14 | 13 |
mounttypes "github.com/docker/docker/api/types/mount" |
| 15 | 14 |
"github.com/docker/docker/container" |
| 15 |
+ "github.com/docker/docker/errdefs" |
|
| 16 | 16 |
"github.com/docker/docker/volume" |
| 17 | 17 |
"github.com/docker/docker/volume/drivers" |
| 18 | 18 |
"github.com/pkg/errors" |
| ... | ... |
@@ -12,8 +12,8 @@ import ( |
| 12 | 12 |
"github.com/docker/distribution/registry/api/v2" |
| 13 | 13 |
"github.com/docker/distribution/registry/client" |
| 14 | 14 |
"github.com/docker/distribution/registry/client/auth" |
| 15 |
- "github.com/docker/docker/api/errdefs" |
|
| 16 | 15 |
"github.com/docker/docker/distribution/xfer" |
| 16 |
+ "github.com/docker/docker/errdefs" |
|
| 17 | 17 |
"github.com/sirupsen/logrus" |
| 18 | 18 |
) |
| 19 | 19 |
|
| 20 | 20 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,74 @@ |
| 0 |
+package errdefs |
|
| 1 |
+ |
|
| 2 |
+// ErrNotFound signals that the requested object doesn't exist |
|
| 3 |
+type ErrNotFound interface {
|
|
| 4 |
+ NotFound() |
|
| 5 |
+} |
|
| 6 |
+ |
|
| 7 |
+// ErrInvalidParameter signals that the user input is invalid |
|
| 8 |
+type ErrInvalidParameter interface {
|
|
| 9 |
+ InvalidParameter() |
|
| 10 |
+} |
|
| 11 |
+ |
|
| 12 |
+// ErrConflict signals that some internal state conflicts with the requested action and can't be performed. |
|
| 13 |
+// A change in state should be able to clear this error. |
|
| 14 |
+type ErrConflict interface {
|
|
| 15 |
+ Conflict() |
|
| 16 |
+} |
|
| 17 |
+ |
|
| 18 |
+// ErrUnauthorized is used to signify that the user is not authorized to perform a specific action |
|
| 19 |
+type ErrUnauthorized interface {
|
|
| 20 |
+ Unauthorized() |
|
| 21 |
+} |
|
| 22 |
+ |
|
| 23 |
+// ErrUnavailable signals that the requested action/subsystem is not available. |
|
| 24 |
+type ErrUnavailable interface {
|
|
| 25 |
+ Unavailable() |
|
| 26 |
+} |
|
| 27 |
+ |
|
| 28 |
+// ErrForbidden signals that the requested action cannot be performed under any circumstances. |
|
| 29 |
+// When a ErrForbidden is returned, the caller should never retry the action. |
|
| 30 |
+type ErrForbidden interface {
|
|
| 31 |
+ Forbidden() |
|
| 32 |
+} |
|
| 33 |
+ |
|
| 34 |
+// ErrSystem signals that some internal error occurred. |
|
| 35 |
+// An example of this would be a failed mount request. |
|
| 36 |
+type ErrSystem interface {
|
|
| 37 |
+ ErrSystem() |
|
| 38 |
+} |
|
| 39 |
+ |
|
| 40 |
+// ErrNotModified signals that an action can't be performed because it's already in the desired state |
|
| 41 |
+type ErrNotModified interface {
|
|
| 42 |
+ NotModified() |
|
| 43 |
+} |
|
| 44 |
+ |
|
| 45 |
+// ErrAlreadyExists is a special case of ErrConflict which signals that the desired object already exists |
|
| 46 |
+type ErrAlreadyExists interface {
|
|
| 47 |
+ AlreadyExists() |
|
| 48 |
+} |
|
| 49 |
+ |
|
| 50 |
+// ErrNotImplemented signals that the requested action/feature is not implemented on the system as configured. |
|
| 51 |
+type ErrNotImplemented interface {
|
|
| 52 |
+ NotImplemented() |
|
| 53 |
+} |
|
| 54 |
+ |
|
| 55 |
+// ErrUnknown signals that the kind of error that occurred is not known. |
|
| 56 |
+type ErrUnknown interface {
|
|
| 57 |
+ Unknown() |
|
| 58 |
+} |
|
| 59 |
+ |
|
| 60 |
+// ErrCancelled signals that the action was cancelled. |
|
| 61 |
+type ErrCancelled interface {
|
|
| 62 |
+ Cancelled() |
|
| 63 |
+} |
|
| 64 |
+ |
|
| 65 |
+// ErrDeadline signals that the deadline was reached before the action completed. |
|
| 66 |
+type ErrDeadline interface {
|
|
| 67 |
+ DeadlineExceeded() |
|
| 68 |
+} |
|
| 69 |
+ |
|
| 70 |
+// ErrDataLoss indicates that data was lost or there is data corruption. |
|
| 71 |
+type ErrDataLoss interface {
|
|
| 72 |
+ DataLoss() |
|
| 73 |
+} |
| 0 | 74 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,8 @@ |
| 0 |
+// Package errdefs defines a set of error interfaces that packages should use for communicating classes of errors. |
|
| 1 |
+// Errors that cross the package boundary should implement one (and only one) of these interfaces. |
|
| 2 |
+// |
|
| 3 |
+// Packages should not reference these interfaces directly, only implement them. |
|
| 4 |
+// To check if a particular error implements one of these interfaces, there are helper |
|
| 5 |
+// functions provided (e.g. `Is<SomeError>`) which can be used rather than asserting the interfaces directly. |
|
| 6 |
+// If you must assert on these interfaces, be sure to check the causal chain (`err.Cause()`). |
|
| 7 |
+package errdefs |
| 0 | 8 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,240 @@ |
| 0 |
+package errdefs |
|
| 1 |
+ |
|
| 2 |
+import "context" |
|
| 3 |
+ |
|
| 4 |
+type errNotFound struct{ error }
|
|
| 5 |
+ |
|
| 6 |
+func (errNotFound) NotFound() {}
|
|
| 7 |
+ |
|
| 8 |
+func (e errNotFound) Cause() error {
|
|
| 9 |
+ return e.error |
|
| 10 |
+} |
|
| 11 |
+ |
|
| 12 |
+// NotFound is a helper to create an error of the class with the same name from any error type |
|
| 13 |
+func NotFound(err error) error {
|
|
| 14 |
+ if err == nil {
|
|
| 15 |
+ return nil |
|
| 16 |
+ } |
|
| 17 |
+ return errNotFound{err}
|
|
| 18 |
+} |
|
| 19 |
+ |
|
| 20 |
+type errInvalidParameter struct{ error }
|
|
| 21 |
+ |
|
| 22 |
+func (errInvalidParameter) InvalidParameter() {}
|
|
| 23 |
+ |
|
| 24 |
+func (e errInvalidParameter) Cause() error {
|
|
| 25 |
+ return e.error |
|
| 26 |
+} |
|
| 27 |
+ |
|
| 28 |
+// InvalidParameter is a helper to create an error of the class with the same name from any error type |
|
| 29 |
+func InvalidParameter(err error) error {
|
|
| 30 |
+ if err == nil {
|
|
| 31 |
+ return nil |
|
| 32 |
+ } |
|
| 33 |
+ return errInvalidParameter{err}
|
|
| 34 |
+} |
|
| 35 |
+ |
|
| 36 |
+type errConflict struct{ error }
|
|
| 37 |
+ |
|
| 38 |
+func (errConflict) Conflict() {}
|
|
| 39 |
+ |
|
| 40 |
+func (e errConflict) Cause() error {
|
|
| 41 |
+ return e.error |
|
| 42 |
+} |
|
| 43 |
+ |
|
| 44 |
+// Conflict is a helper to create an error of the class with the same name from any error type |
|
| 45 |
+func Conflict(err error) error {
|
|
| 46 |
+ if err == nil {
|
|
| 47 |
+ return nil |
|
| 48 |
+ } |
|
| 49 |
+ return errConflict{err}
|
|
| 50 |
+} |
|
| 51 |
+ |
|
| 52 |
+type errUnauthorized struct{ error }
|
|
| 53 |
+ |
|
| 54 |
+func (errUnauthorized) Unauthorized() {}
|
|
| 55 |
+ |
|
| 56 |
+func (e errUnauthorized) Cause() error {
|
|
| 57 |
+ return e.error |
|
| 58 |
+} |
|
| 59 |
+ |
|
| 60 |
+// Unauthorized is a helper to create an error of the class with the same name from any error type |
|
| 61 |
+func Unauthorized(err error) error {
|
|
| 62 |
+ if err == nil {
|
|
| 63 |
+ return nil |
|
| 64 |
+ } |
|
| 65 |
+ return errUnauthorized{err}
|
|
| 66 |
+} |
|
| 67 |
+ |
|
| 68 |
+type errUnavailable struct{ error }
|
|
| 69 |
+ |
|
| 70 |
+func (errUnavailable) Unavailable() {}
|
|
| 71 |
+ |
|
| 72 |
+func (e errUnavailable) Cause() error {
|
|
| 73 |
+ return e.error |
|
| 74 |
+} |
|
| 75 |
+ |
|
| 76 |
+// Unavailable is a helper to create an error of the class with the same name from any error type |
|
| 77 |
+func Unavailable(err error) error {
|
|
| 78 |
+ return errUnavailable{err}
|
|
| 79 |
+} |
|
| 80 |
+ |
|
| 81 |
+type errForbidden struct{ error }
|
|
| 82 |
+ |
|
| 83 |
+func (errForbidden) Forbidden() {}
|
|
| 84 |
+ |
|
| 85 |
+func (e errForbidden) Cause() error {
|
|
| 86 |
+ return e.error |
|
| 87 |
+} |
|
| 88 |
+ |
|
| 89 |
+// Forbidden is a helper to create an error of the class with the same name from any error type |
|
| 90 |
+func Forbidden(err error) error {
|
|
| 91 |
+ if err == nil {
|
|
| 92 |
+ return nil |
|
| 93 |
+ } |
|
| 94 |
+ return errForbidden{err}
|
|
| 95 |
+} |
|
| 96 |
+ |
|
| 97 |
+type errSystem struct{ error }
|
|
| 98 |
+ |
|
| 99 |
+func (errSystem) System() {}
|
|
| 100 |
+ |
|
| 101 |
+func (e errSystem) Cause() error {
|
|
| 102 |
+ return e.error |
|
| 103 |
+} |
|
| 104 |
+ |
|
| 105 |
+// System is a helper to create an error of the class with the same name from any error type |
|
| 106 |
+func System(err error) error {
|
|
| 107 |
+ if err == nil {
|
|
| 108 |
+ return nil |
|
| 109 |
+ } |
|
| 110 |
+ return errSystem{err}
|
|
| 111 |
+} |
|
| 112 |
+ |
|
| 113 |
+type errNotModified struct{ error }
|
|
| 114 |
+ |
|
| 115 |
+func (errNotModified) NotModified() {}
|
|
| 116 |
+ |
|
| 117 |
+func (e errNotModified) Cause() error {
|
|
| 118 |
+ return e.error |
|
| 119 |
+} |
|
| 120 |
+ |
|
| 121 |
+// NotModified is a helper to create an error of the class with the same name from any error type |
|
| 122 |
+func NotModified(err error) error {
|
|
| 123 |
+ if err == nil {
|
|
| 124 |
+ return nil |
|
| 125 |
+ } |
|
| 126 |
+ return errNotModified{err}
|
|
| 127 |
+} |
|
| 128 |
+ |
|
| 129 |
+type errAlreadyExists struct{ error }
|
|
| 130 |
+ |
|
| 131 |
+func (errAlreadyExists) AlreadyExists() {}
|
|
| 132 |
+ |
|
| 133 |
+func (e errAlreadyExists) Cause() error {
|
|
| 134 |
+ return e.error |
|
| 135 |
+} |
|
| 136 |
+ |
|
| 137 |
+// AlreadyExists is a helper to create an error of the class with the same name from any error type |
|
| 138 |
+func AlreadyExists(err error) error {
|
|
| 139 |
+ if err == nil {
|
|
| 140 |
+ return nil |
|
| 141 |
+ } |
|
| 142 |
+ return errAlreadyExists{err}
|
|
| 143 |
+} |
|
| 144 |
+ |
|
| 145 |
+type errNotImplemented struct{ error }
|
|
| 146 |
+ |
|
| 147 |
+func (errNotImplemented) NotImplemented() {}
|
|
| 148 |
+ |
|
| 149 |
+func (e errNotImplemented) Cause() error {
|
|
| 150 |
+ return e.error |
|
| 151 |
+} |
|
| 152 |
+ |
|
| 153 |
+// NotImplemented is a helper to create an error of the class with the same name from any error type |
|
| 154 |
+func NotImplemented(err error) error {
|
|
| 155 |
+ if err == nil {
|
|
| 156 |
+ return nil |
|
| 157 |
+ } |
|
| 158 |
+ return errNotImplemented{err}
|
|
| 159 |
+} |
|
| 160 |
+ |
|
| 161 |
+type errUnknown struct{ error }
|
|
| 162 |
+ |
|
| 163 |
+func (errUnknown) Unknown() {}
|
|
| 164 |
+ |
|
| 165 |
+func (e errUnknown) Cause() error {
|
|
| 166 |
+ return e.error |
|
| 167 |
+} |
|
| 168 |
+ |
|
| 169 |
+// Unknown is a helper to create an error of the class with the same name from any error type |
|
| 170 |
+func Unknown(err error) error {
|
|
| 171 |
+ if err == nil {
|
|
| 172 |
+ return nil |
|
| 173 |
+ } |
|
| 174 |
+ return errUnknown{err}
|
|
| 175 |
+} |
|
| 176 |
+ |
|
| 177 |
+type errCancelled struct{ error }
|
|
| 178 |
+ |
|
| 179 |
+func (errCancelled) Cancelled() {}
|
|
| 180 |
+ |
|
| 181 |
+func (e errCancelled) Cause() error {
|
|
| 182 |
+ return e.error |
|
| 183 |
+} |
|
| 184 |
+ |
|
| 185 |
+// Cancelled is a helper to create an error of the class with the same name from any error type |
|
| 186 |
+func Cancelled(err error) error {
|
|
| 187 |
+ if err == nil {
|
|
| 188 |
+ return nil |
|
| 189 |
+ } |
|
| 190 |
+ return errCancelled{err}
|
|
| 191 |
+} |
|
| 192 |
+ |
|
| 193 |
+type errDeadline struct{ error }
|
|
| 194 |
+ |
|
| 195 |
+func (errDeadline) DeadlineExceeded() {}
|
|
| 196 |
+ |
|
| 197 |
+func (e errDeadline) Cause() error {
|
|
| 198 |
+ return e.error |
|
| 199 |
+} |
|
| 200 |
+ |
|
| 201 |
+// Deadline is a helper to create an error of the class with the same name from any error type |
|
| 202 |
+func Deadline(err error) error {
|
|
| 203 |
+ if err == nil {
|
|
| 204 |
+ return nil |
|
| 205 |
+ } |
|
| 206 |
+ return errDeadline{err}
|
|
| 207 |
+} |
|
| 208 |
+ |
|
| 209 |
+type errDataLoss struct{ error }
|
|
| 210 |
+ |
|
| 211 |
+func (errDataLoss) DataLoss() {}
|
|
| 212 |
+ |
|
| 213 |
+func (e errDataLoss) Cause() error {
|
|
| 214 |
+ return e.error |
|
| 215 |
+} |
|
| 216 |
+ |
|
| 217 |
+// DataLoss is a helper to create an error of the class with the same name from any error type |
|
| 218 |
+func DataLoss(err error) error {
|
|
| 219 |
+ if err == nil {
|
|
| 220 |
+ return nil |
|
| 221 |
+ } |
|
| 222 |
+ return errDataLoss{err}
|
|
| 223 |
+} |
|
| 224 |
+ |
|
| 225 |
+// FromContext returns the error class from the passed in context |
|
| 226 |
+func FromContext(ctx context.Context) error {
|
|
| 227 |
+ e := ctx.Err() |
|
| 228 |
+ if e == nil {
|
|
| 229 |
+ return nil |
|
| 230 |
+ } |
|
| 231 |
+ |
|
| 232 |
+ if e == context.Canceled {
|
|
| 233 |
+ return Cancelled(e) |
|
| 234 |
+ } |
|
| 235 |
+ if e == context.DeadlineExceeded {
|
|
| 236 |
+ return Deadline(e) |
|
| 237 |
+ } |
|
| 238 |
+ return Unknown(e) |
|
| 239 |
+} |
| 0 | 240 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,132 @@ |
| 0 |
+package errdefs |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "errors" |
|
| 4 |
+ "testing" |
|
| 5 |
+) |
|
| 6 |
+ |
|
| 7 |
+var errTest = errors.New("this is a test")
|
|
| 8 |
+ |
|
| 9 |
+type causal interface {
|
|
| 10 |
+ Cause() error |
|
| 11 |
+} |
|
| 12 |
+ |
|
| 13 |
+func TestNotFound(t *testing.T) {
|
|
| 14 |
+ e := NotFound(errTest) |
|
| 15 |
+ if !IsNotFound(e) {
|
|
| 16 |
+ t.Fatalf("expected not found error, got: %T", e)
|
|
| 17 |
+ } |
|
| 18 |
+ if cause := e.(causal).Cause(); cause != errTest {
|
|
| 19 |
+ t.Fatalf("causual should be errTest, got: %v", cause)
|
|
| 20 |
+ } |
|
| 21 |
+} |
|
| 22 |
+ |
|
| 23 |
+func TestConflict(t *testing.T) {
|
|
| 24 |
+ e := Conflict(errTest) |
|
| 25 |
+ if !IsConflict(e) {
|
|
| 26 |
+ t.Fatalf("expected conflcit error, got: %T", e)
|
|
| 27 |
+ } |
|
| 28 |
+ if cause := e.(causal).Cause(); cause != errTest {
|
|
| 29 |
+ t.Fatalf("causual should be errTest, got: %v", cause)
|
|
| 30 |
+ } |
|
| 31 |
+} |
|
| 32 |
+ |
|
| 33 |
+func TestForbidden(t *testing.T) {
|
|
| 34 |
+ e := Forbidden(errTest) |
|
| 35 |
+ if !IsForbidden(e) {
|
|
| 36 |
+ t.Fatalf("expected forbidden error, got: %T", e)
|
|
| 37 |
+ } |
|
| 38 |
+ if cause := e.(causal).Cause(); cause != errTest {
|
|
| 39 |
+ t.Fatalf("causual should be errTest, got: %v", cause)
|
|
| 40 |
+ } |
|
| 41 |
+} |
|
| 42 |
+ |
|
| 43 |
+func TestInvalidParameter(t *testing.T) {
|
|
| 44 |
+ e := InvalidParameter(errTest) |
|
| 45 |
+ if !IsInvalidParameter(e) {
|
|
| 46 |
+ t.Fatalf("expected invalid argument error, got %T", e)
|
|
| 47 |
+ } |
|
| 48 |
+ if cause := e.(causal).Cause(); cause != errTest {
|
|
| 49 |
+ t.Fatalf("causual should be errTest, got: %v", cause)
|
|
| 50 |
+ } |
|
| 51 |
+} |
|
| 52 |
+ |
|
| 53 |
+func TestNotImplemented(t *testing.T) {
|
|
| 54 |
+ e := NotImplemented(errTest) |
|
| 55 |
+ if !IsNotImplemented(e) {
|
|
| 56 |
+ t.Fatalf("expected not implemented error, got %T", e)
|
|
| 57 |
+ } |
|
| 58 |
+ if cause := e.(causal).Cause(); cause != errTest {
|
|
| 59 |
+ t.Fatalf("causual should be errTest, got: %v", cause)
|
|
| 60 |
+ } |
|
| 61 |
+} |
|
| 62 |
+ |
|
| 63 |
+func TestNotModified(t *testing.T) {
|
|
| 64 |
+ e := NotModified(errTest) |
|
| 65 |
+ if !IsNotModified(e) {
|
|
| 66 |
+ t.Fatalf("expected not modified error, got %T", e)
|
|
| 67 |
+ } |
|
| 68 |
+ if cause := e.(causal).Cause(); cause != errTest {
|
|
| 69 |
+ t.Fatalf("causual should be errTest, got: %v", cause)
|
|
| 70 |
+ } |
|
| 71 |
+} |
|
| 72 |
+ |
|
| 73 |
+func TestAlreadyExists(t *testing.T) {
|
|
| 74 |
+ e := AlreadyExists(errTest) |
|
| 75 |
+ if !IsAlreadyExists(e) {
|
|
| 76 |
+ t.Fatalf("expected already exists error, got %T", e)
|
|
| 77 |
+ } |
|
| 78 |
+ if cause := e.(causal).Cause(); cause != errTest {
|
|
| 79 |
+ t.Fatalf("causual should be errTest, got: %v", cause)
|
|
| 80 |
+ } |
|
| 81 |
+} |
|
| 82 |
+ |
|
| 83 |
+func TestUnauthorized(t *testing.T) {
|
|
| 84 |
+ e := Unauthorized(errTest) |
|
| 85 |
+ if !IsUnauthorized(e) {
|
|
| 86 |
+ t.Fatalf("expected unauthorized error, got %T", e)
|
|
| 87 |
+ } |
|
| 88 |
+ if cause := e.(causal).Cause(); cause != errTest {
|
|
| 89 |
+ t.Fatalf("causual should be errTest, got: %v", cause)
|
|
| 90 |
+ } |
|
| 91 |
+} |
|
| 92 |
+ |
|
| 93 |
+func TestUnknown(t *testing.T) {
|
|
| 94 |
+ e := Unknown(errTest) |
|
| 95 |
+ if !IsUnknown(e) {
|
|
| 96 |
+ t.Fatalf("expected unknown error, got %T", e)
|
|
| 97 |
+ } |
|
| 98 |
+ if cause := e.(causal).Cause(); cause != errTest {
|
|
| 99 |
+ t.Fatalf("causual should be errTest, got: %v", cause)
|
|
| 100 |
+ } |
|
| 101 |
+} |
|
| 102 |
+ |
|
| 103 |
+func TestCancelled(t *testing.T) {
|
|
| 104 |
+ e := Cancelled(errTest) |
|
| 105 |
+ if !IsCancelled(e) {
|
|
| 106 |
+ t.Fatalf("expected canclled error, got %T", e)
|
|
| 107 |
+ } |
|
| 108 |
+ if cause := e.(causal).Cause(); cause != errTest {
|
|
| 109 |
+ t.Fatalf("causual should be errTest, got: %v", cause)
|
|
| 110 |
+ } |
|
| 111 |
+} |
|
| 112 |
+ |
|
| 113 |
+func TestDeadline(t *testing.T) {
|
|
| 114 |
+ e := Deadline(errTest) |
|
| 115 |
+ if !IsDeadline(e) {
|
|
| 116 |
+ t.Fatalf("expected deadline error, got %T", e)
|
|
| 117 |
+ } |
|
| 118 |
+ if cause := e.(causal).Cause(); cause != errTest {
|
|
| 119 |
+ t.Fatalf("causual should be errTest, got: %v", cause)
|
|
| 120 |
+ } |
|
| 121 |
+} |
|
| 122 |
+ |
|
| 123 |
+func TestIsDataLoss(t *testing.T) {
|
|
| 124 |
+ e := DataLoss(errTest) |
|
| 125 |
+ if !IsDataLoss(e) {
|
|
| 126 |
+ t.Fatalf("expected data loss error, got %T", e)
|
|
| 127 |
+ } |
|
| 128 |
+ if cause := e.(causal).Cause(); cause != errTest {
|
|
| 129 |
+ t.Fatalf("causual should be errTest, got: %v", cause)
|
|
| 130 |
+ } |
|
| 131 |
+} |
| 0 | 132 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,114 @@ |
| 0 |
+package errdefs |
|
| 1 |
+ |
|
| 2 |
+type causer interface {
|
|
| 3 |
+ Cause() error |
|
| 4 |
+} |
|
| 5 |
+ |
|
| 6 |
+func getImplementer(err error) error {
|
|
| 7 |
+ switch e := err.(type) {
|
|
| 8 |
+ case |
|
| 9 |
+ ErrNotFound, |
|
| 10 |
+ ErrInvalidParameter, |
|
| 11 |
+ ErrConflict, |
|
| 12 |
+ ErrUnauthorized, |
|
| 13 |
+ ErrUnavailable, |
|
| 14 |
+ ErrForbidden, |
|
| 15 |
+ ErrSystem, |
|
| 16 |
+ ErrNotModified, |
|
| 17 |
+ ErrAlreadyExists, |
|
| 18 |
+ ErrNotImplemented, |
|
| 19 |
+ ErrCancelled, |
|
| 20 |
+ ErrDeadline, |
|
| 21 |
+ ErrDataLoss, |
|
| 22 |
+ ErrUnknown: |
|
| 23 |
+ return e |
|
| 24 |
+ case causer: |
|
| 25 |
+ return getImplementer(e.Cause()) |
|
| 26 |
+ default: |
|
| 27 |
+ return err |
|
| 28 |
+ } |
|
| 29 |
+} |
|
| 30 |
+ |
|
| 31 |
+// IsNotFound returns if the passed in error is an ErrNotFound |
|
| 32 |
+func IsNotFound(err error) bool {
|
|
| 33 |
+ _, ok := getImplementer(err).(ErrNotFound) |
|
| 34 |
+ return ok |
|
| 35 |
+} |
|
| 36 |
+ |
|
| 37 |
+// IsInvalidParameter returns if the passed in error is an ErrInvalidParameter |
|
| 38 |
+func IsInvalidParameter(err error) bool {
|
|
| 39 |
+ _, ok := getImplementer(err).(ErrInvalidParameter) |
|
| 40 |
+ return ok |
|
| 41 |
+} |
|
| 42 |
+ |
|
| 43 |
+// IsConflict returns if the passed in error is an ErrConflict |
|
| 44 |
+func IsConflict(err error) bool {
|
|
| 45 |
+ _, ok := getImplementer(err).(ErrConflict) |
|
| 46 |
+ return ok |
|
| 47 |
+} |
|
| 48 |
+ |
|
| 49 |
+// IsUnauthorized returns if the the passed in error is an ErrUnauthorized |
|
| 50 |
+func IsUnauthorized(err error) bool {
|
|
| 51 |
+ _, ok := getImplementer(err).(ErrUnauthorized) |
|
| 52 |
+ return ok |
|
| 53 |
+} |
|
| 54 |
+ |
|
| 55 |
+// IsUnavailable returns if the passed in error is an ErrUnavailable |
|
| 56 |
+func IsUnavailable(err error) bool {
|
|
| 57 |
+ _, ok := getImplementer(err).(ErrUnavailable) |
|
| 58 |
+ return ok |
|
| 59 |
+} |
|
| 60 |
+ |
|
| 61 |
+// IsForbidden returns if the passed in error is an ErrForbidden |
|
| 62 |
+func IsForbidden(err error) bool {
|
|
| 63 |
+ _, ok := getImplementer(err).(ErrForbidden) |
|
| 64 |
+ return ok |
|
| 65 |
+} |
|
| 66 |
+ |
|
| 67 |
+// IsSystem returns if the passed in error is an ErrSystem |
|
| 68 |
+func IsSystem(err error) bool {
|
|
| 69 |
+ _, ok := getImplementer(err).(ErrSystem) |
|
| 70 |
+ return ok |
|
| 71 |
+} |
|
| 72 |
+ |
|
| 73 |
+// IsNotModified returns if the passed in error is a NotModified error |
|
| 74 |
+func IsNotModified(err error) bool {
|
|
| 75 |
+ _, ok := getImplementer(err).(ErrNotModified) |
|
| 76 |
+ return ok |
|
| 77 |
+} |
|
| 78 |
+ |
|
| 79 |
+// IsAlreadyExists returns if the passed in error is a AlreadyExists error |
|
| 80 |
+func IsAlreadyExists(err error) bool {
|
|
| 81 |
+ _, ok := getImplementer(err).(ErrAlreadyExists) |
|
| 82 |
+ return ok |
|
| 83 |
+} |
|
| 84 |
+ |
|
| 85 |
+// IsNotImplemented returns if the passed in error is an ErrNotImplemented |
|
| 86 |
+func IsNotImplemented(err error) bool {
|
|
| 87 |
+ _, ok := getImplementer(err).(ErrNotImplemented) |
|
| 88 |
+ return ok |
|
| 89 |
+} |
|
| 90 |
+ |
|
| 91 |
+// IsUnknown returns if the passed in error is an ErrUnknown |
|
| 92 |
+func IsUnknown(err error) bool {
|
|
| 93 |
+ _, ok := getImplementer(err).(ErrUnknown) |
|
| 94 |
+ return ok |
|
| 95 |
+} |
|
| 96 |
+ |
|
| 97 |
+// IsCancelled returns if the passed in error is an ErrCancelled |
|
| 98 |
+func IsCancelled(err error) bool {
|
|
| 99 |
+ _, ok := getImplementer(err).(ErrCancelled) |
|
| 100 |
+ return ok |
|
| 101 |
+} |
|
| 102 |
+ |
|
| 103 |
+// IsDeadline returns if the passed in error is an ErrDeadline |
|
| 104 |
+func IsDeadline(err error) bool {
|
|
| 105 |
+ _, ok := getImplementer(err).(ErrDeadline) |
|
| 106 |
+ return ok |
|
| 107 |
+} |
|
| 108 |
+ |
|
| 109 |
+// IsDataLoss returns if the passed in error is an ErrDataLoss |
|
| 110 |
+func IsDataLoss(err error) bool {
|
|
| 111 |
+ _, ok := getImplementer(err).(ErrDataLoss) |
|
| 112 |
+ return ok |
|
| 113 |
+} |
| ... | ... |
@@ -31,7 +31,7 @@ import ( |
| 31 | 31 |
"github.com/containerd/containerd/images" |
| 32 | 32 |
"github.com/containerd/containerd/linux/runctypes" |
| 33 | 33 |
"github.com/containerd/typeurl" |
| 34 |
- "github.com/docker/docker/api/errdefs" |
|
| 34 |
+ "github.com/docker/docker/errdefs" |
|
| 35 | 35 |
"github.com/docker/docker/pkg/ioutils" |
| 36 | 36 |
"github.com/opencontainers/image-spec/specs-go/v1" |
| 37 | 37 |
specs "github.com/opencontainers/runtime-spec/specs-go" |
| ... | ... |
@@ -14,13 +14,13 @@ import ( |
| 14 | 14 |
|
| 15 | 15 |
"github.com/docker/distribution/manifest/schema2" |
| 16 | 16 |
"github.com/docker/distribution/reference" |
| 17 |
- "github.com/docker/docker/api/errdefs" |
|
| 18 | 17 |
"github.com/docker/docker/api/types" |
| 19 | 18 |
"github.com/docker/docker/api/types/filters" |
| 20 | 19 |
"github.com/docker/docker/distribution" |
| 21 | 20 |
progressutils "github.com/docker/docker/distribution/utils" |
| 22 | 21 |
"github.com/docker/docker/distribution/xfer" |
| 23 | 22 |
"github.com/docker/docker/dockerversion" |
| 23 |
+ "github.com/docker/docker/errdefs" |
|
| 24 | 24 |
"github.com/docker/docker/image" |
| 25 | 25 |
"github.com/docker/docker/layer" |
| 26 | 26 |
"github.com/docker/docker/pkg/authorization" |
| ... | ... |
@@ -8,7 +8,7 @@ import ( |
| 8 | 8 |
|
| 9 | 9 |
"github.com/containerd/containerd/cio" |
| 10 | 10 |
"github.com/containerd/containerd/linux/runctypes" |
| 11 |
- "github.com/docker/docker/api/errdefs" |
|
| 11 |
+ "github.com/docker/docker/errdefs" |
|
| 12 | 12 |
"github.com/docker/docker/libcontainerd" |
| 13 | 13 |
"github.com/opencontainers/runtime-spec/specs-go" |
| 14 | 14 |
"github.com/pkg/errors" |
| ... | ... |
@@ -7,9 +7,9 @@ import ( |
| 7 | 7 |
"path/filepath" |
| 8 | 8 |
"time" |
| 9 | 9 |
|
| 10 |
- "github.com/docker/docker/api/errdefs" |
|
| 11 | 10 |
"github.com/docker/docker/api/types" |
| 12 | 11 |
"github.com/docker/docker/daemon/initlayer" |
| 12 |
+ "github.com/docker/docker/errdefs" |
|
| 13 | 13 |
"github.com/docker/docker/pkg/containerfs" |
| 14 | 14 |
"github.com/docker/docker/pkg/idtools" |
| 15 | 15 |
"github.com/docker/docker/pkg/mount" |
| ... | ... |
@@ -5,7 +5,7 @@ import ( |
| 5 | 5 |
"strings" |
| 6 | 6 |
|
| 7 | 7 |
"github.com/docker/distribution/reference" |
| 8 |
- "github.com/docker/docker/api/errdefs" |
|
| 8 |
+ "github.com/docker/docker/errdefs" |
|
| 9 | 9 |
"github.com/docker/docker/pkg/plugingetter" |
| 10 | 10 |
"github.com/docker/docker/pkg/plugins" |
| 11 | 11 |
"github.com/docker/docker/plugin/v2" |
| ... | ... |
@@ -10,9 +10,9 @@ import ( |
| 10 | 10 |
"github.com/docker/distribution/registry/client/auth" |
| 11 | 11 |
"github.com/docker/distribution/registry/client/auth/challenge" |
| 12 | 12 |
"github.com/docker/distribution/registry/client/transport" |
| 13 |
- "github.com/docker/docker/api/errdefs" |
|
| 14 | 13 |
"github.com/docker/docker/api/types" |
| 15 | 14 |
registrytypes "github.com/docker/docker/api/types/registry" |
| 15 |
+ "github.com/docker/docker/errdefs" |
|
| 16 | 16 |
"github.com/pkg/errors" |
| 17 | 17 |
"github.com/sirupsen/logrus" |
| 18 | 18 |
) |
| ... | ... |
@@ -11,9 +11,9 @@ import ( |
| 11 | 11 |
|
| 12 | 12 |
"github.com/docker/distribution/reference" |
| 13 | 13 |
"github.com/docker/distribution/registry/client/auth" |
| 14 |
- "github.com/docker/docker/api/errdefs" |
|
| 15 | 14 |
"github.com/docker/docker/api/types" |
| 16 | 15 |
registrytypes "github.com/docker/docker/api/types/registry" |
| 16 |
+ "github.com/docker/docker/errdefs" |
|
| 17 | 17 |
"github.com/pkg/errors" |
| 18 | 18 |
"github.com/sirupsen/logrus" |
| 19 | 19 |
) |
| ... | ... |
@@ -19,9 +19,9 @@ import ( |
| 19 | 19 |
|
| 20 | 20 |
"github.com/docker/distribution/reference" |
| 21 | 21 |
"github.com/docker/distribution/registry/api/errcode" |
| 22 |
- "github.com/docker/docker/api/errdefs" |
|
| 23 | 22 |
"github.com/docker/docker/api/types" |
| 24 | 23 |
registrytypes "github.com/docker/docker/api/types/registry" |
| 24 |
+ "github.com/docker/docker/errdefs" |
|
| 25 | 25 |
"github.com/docker/docker/pkg/ioutils" |
| 26 | 26 |
"github.com/docker/docker/pkg/jsonmessage" |
| 27 | 27 |
"github.com/docker/docker/pkg/stringid" |
| ... | ... |
@@ -13,8 +13,8 @@ import ( |
| 13 | 13 |
"strings" |
| 14 | 14 |
"sync" |
| 15 | 15 |
|
| 16 |
- "github.com/docker/docker/api/errdefs" |
|
| 17 | 16 |
"github.com/docker/docker/daemon/names" |
| 17 |
+ "github.com/docker/docker/errdefs" |
|
| 18 | 18 |
"github.com/docker/docker/pkg/idtools" |
| 19 | 19 |
"github.com/docker/docker/pkg/mount" |
| 20 | 20 |
"github.com/docker/docker/volume" |