diff options
author | Tibor Vass <tiborvass@users.noreply.github.com> | 2015-09-23 19:15:25 -0400 |
---|---|---|
committer | Tibor Vass <tiborvass@users.noreply.github.com> | 2015-09-23 19:15:25 -0400 |
commit | 793a40908155c87435e676646a23a413616dda6d (patch) | |
tree | bfc56693b02a42bf40be4d4afb9284c2b10b66bf | |
parent | 01670bec48e3302c3571e7369e57fa0f092bbdf2 (diff) | |
parent | da0ca83377db0228db82b7be4096b34e3ebfb114 (diff) | |
download | docker-793a40908155c87435e676646a23a413616dda6d.tar.gz |
Merge pull request #16504 from brahmaroutu/ImageErrors
Adding error codes to image package
-rw-r--r-- | errors/image.go | 20 | ||||
-rw-r--r-- | image/image.go | 4 |
2 files changed, 22 insertions, 2 deletions
diff --git a/errors/image.go b/errors/image.go new file mode 100644 index 0000000000..04efe6fcba --- /dev/null +++ b/errors/image.go @@ -0,0 +1,20 @@ +package errors + +// This file contains all of the errors that can be generated from the +// docker/image component. + +import ( + "net/http" + + "github.com/docker/distribution/registry/api/errcode" +) + +var ( + // ErrorCodeInvalidImageID is generated when image id specified is incorrectly formatted. + ErrorCodeInvalidImageID = errcode.Register(errGroup, errcode.ErrorDescriptor{ + Value: "INVALIDIMAGEID", + Message: "image ID '%s' is invalid ", + Description: "The specified image id is incorrectly formatted", + HTTPStatusCode: http.StatusInternalServerError, + }) +) diff --git a/image/image.go b/image/image.go index a405b538fb..e069262eac 100644 --- a/image/image.go +++ b/image/image.go @@ -2,10 +2,10 @@ package image import ( "encoding/json" - "fmt" "regexp" "time" + derr "github.com/docker/docker/errors" "github.com/docker/docker/runconfig" ) @@ -53,7 +53,7 @@ func NewImgJSON(src []byte) (*Image, error) { // ValidateID checks whether an ID string is a valid image ID. func ValidateID(id string) error { if ok := validHex.MatchString(id); !ok { - return fmt.Errorf("image ID '%s' is invalid", id) + return derr.ErrorCodeInvalidImageID.WithArgs(id) } return nil } |