Pass through known errors

Signed-off-by: Troels Thomsen <troels@thomsen.io>
This commit is contained in:
Troels Thomsen 2016-04-29 23:34:24 +02:00
parent ba927007b0
commit 3730470b64
4 changed files with 8 additions and 0 deletions

View file

@ -634,6 +634,8 @@ func (app *App) dispatcher(dispatch dispatchFunc) http.Handler {
context.Errors = append(context.Errors, v2.ErrorCodeNameUnknown.WithDetail(err)) context.Errors = append(context.Errors, v2.ErrorCodeNameUnknown.WithDetail(err))
case distribution.ErrRepositoryNameInvalid: case distribution.ErrRepositoryNameInvalid:
context.Errors = append(context.Errors, v2.ErrorCodeNameInvalid.WithDetail(err)) context.Errors = append(context.Errors, v2.ErrorCodeNameInvalid.WithDetail(err))
case errcode.Error:
context.Errors = append(context.Errors, err)
} }
if err := errcode.ServeJSON(w, context.Errors); err != nil { if err := errcode.ServeJSON(w, context.Errors); err != nil {

View file

@ -239,6 +239,8 @@ func (buh *blobUploadHandler) PutBlobUploadComplete(w http.ResponseWriter, r *ht
switch err := err.(type) { switch err := err.(type) {
case distribution.ErrBlobInvalidDigest: case distribution.ErrBlobInvalidDigest:
buh.Errors = append(buh.Errors, v2.ErrorCodeDigestInvalid.WithDetail(err)) buh.Errors = append(buh.Errors, v2.ErrorCodeDigestInvalid.WithDetail(err))
case errcode.Error:
buh.Errors = append(buh.Errors, err)
default: default:
switch err { switch err {
case distribution.ErrAccessDenied: case distribution.ErrAccessDenied:

View file

@ -283,6 +283,8 @@ func (imh *imageManifestHandler) PutImageManifest(w http.ResponseWriter, r *http
} }
} }
} }
case errcode.Error:
imh.Errors = append(imh.Errors, err)
default: default:
imh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown.WithDetail(err)) imh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown.WithDetail(err))
} }

View file

@ -41,6 +41,8 @@ func (th *tagsHandler) GetTags(w http.ResponseWriter, r *http.Request) {
switch err := err.(type) { switch err := err.(type) {
case distribution.ErrRepositoryUnknown: case distribution.ErrRepositoryUnknown:
th.Errors = append(th.Errors, v2.ErrorCodeNameUnknown.WithDetail(map[string]string{"name": th.Repository.Named().Name()})) th.Errors = append(th.Errors, v2.ErrorCodeNameUnknown.WithDetail(map[string]string{"name": th.Repository.Named().Name()}))
case errcode.Error:
th.Errors = append(th.Errors, err)
default: default:
th.Errors = append(th.Errors, errcode.ErrorCodeUnknown.WithDetail(err)) th.Errors = append(th.Errors, errcode.ErrorCodeUnknown.WithDetail(err))
} }