From 3730470b641dcb7ebe50e32512ad4565fa340027 Mon Sep 17 00:00:00 2001 From: Troels Thomsen Date: Fri, 29 Apr 2016 23:34:24 +0200 Subject: [PATCH] Pass through known errors Signed-off-by: Troels Thomsen --- registry/handlers/app.go | 2 ++ registry/handlers/blobupload.go | 2 ++ registry/handlers/images.go | 2 ++ registry/handlers/tags.go | 2 ++ 4 files changed, 8 insertions(+) diff --git a/registry/handlers/app.go b/registry/handlers/app.go index 3c3e50d0b..fc3f90695 100644 --- a/registry/handlers/app.go +++ b/registry/handlers/app.go @@ -634,6 +634,8 @@ func (app *App) dispatcher(dispatch dispatchFunc) http.Handler { context.Errors = append(context.Errors, v2.ErrorCodeNameUnknown.WithDetail(err)) case distribution.ErrRepositoryNameInvalid: 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 { diff --git a/registry/handlers/blobupload.go b/registry/handlers/blobupload.go index 673e2c591..2cd5115d1 100644 --- a/registry/handlers/blobupload.go +++ b/registry/handlers/blobupload.go @@ -239,6 +239,8 @@ func (buh *blobUploadHandler) PutBlobUploadComplete(w http.ResponseWriter, r *ht switch err := err.(type) { case distribution.ErrBlobInvalidDigest: buh.Errors = append(buh.Errors, v2.ErrorCodeDigestInvalid.WithDetail(err)) + case errcode.Error: + buh.Errors = append(buh.Errors, err) default: switch err { case distribution.ErrAccessDenied: diff --git a/registry/handlers/images.go b/registry/handlers/images.go index 5f2d88559..dd2ed2c84 100644 --- a/registry/handlers/images.go +++ b/registry/handlers/images.go @@ -283,6 +283,8 @@ func (imh *imageManifestHandler) PutImageManifest(w http.ResponseWriter, r *http } } } + case errcode.Error: + imh.Errors = append(imh.Errors, err) default: imh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown.WithDetail(err)) } diff --git a/registry/handlers/tags.go b/registry/handlers/tags.go index fd661e663..91f1031e3 100644 --- a/registry/handlers/tags.go +++ b/registry/handlers/tags.go @@ -41,6 +41,8 @@ func (th *tagsHandler) GetTags(w http.ResponseWriter, r *http.Request) { switch err := err.(type) { case distribution.ErrRepositoryUnknown: 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: th.Errors = append(th.Errors, errcode.ErrorCodeUnknown.WithDetail(err)) }