rename errcodeErrorsFor -> toErrcodeErrors

Signed-off-by: darshanime <darshan@argonaut.dev>
This commit is contained in:
darshanime
2026-07-20 22:28:43 +05:30
parent c6903beb8e
commit 5077b0741a
4 changed files with 7 additions and 7 deletions

View File

@@ -60,14 +60,14 @@ func (bh *blobHandler) GetBlob(w http.ResponseWriter, r *http.Request) {
if err == distribution.ErrBlobUnknown {
bh.Errors = append(bh.Errors, errcode.ErrorCodeBlobUnknown.WithDetail(bh.Digest))
} else {
bh.Errors = append(bh.Errors, errcodeErrorsFor(err)...)
bh.Errors = append(bh.Errors, toErrcodeErrors(err)...)
}
return
}
if err := blobs.ServeBlob(bh, w, r, desc.Digest); err != nil {
dcontext.GetLogger(bh).Debugf("unexpected error getting blob HTTP handler: %v", err)
bh.Errors = append(bh.Errors, errcodeErrorsFor(err)...)
bh.Errors = append(bh.Errors, toErrcodeErrors(err)...)
return
}
}

View File

@@ -85,12 +85,12 @@ func parseContentRange(cr string) (start int64, end int64, err error) {
return start, end, nil
}
// errcodeErrorsFor converts err into the errcode.Errors reported to the client.
// toErrcodeErrors converts err into the errcode.Errors reported to the client.
// When err already carries one or more registry error codes (for eg 401/403),
// those codes are preserved so the client receives the correct status instead
// of a generic internal server error. Errors that do not carry a code are reported
// as ErrorCodeUnknown, preserving the previous behaviour.
func errcodeErrorsFor(err error) errcode.Errors {
func toErrcodeErrors(err error) errcode.Errors {
switch err := err.(type) {
case errcode.Errors:
return err

View File

@@ -35,7 +35,7 @@ func TestErrcodeErrorsFor(t *testing.T) {
},
} {
t.Run(tc.name, func(t *testing.T) {
got := errcodeErrorsFor(tc.err)
got := toErrcodeErrors(tc.err)
if len(got) == 0 {
t.Fatalf("errcodeErrorsFor(%v) returned no errors", tc.err)
}

View File

@@ -124,7 +124,7 @@ func (imh *manifestHandler) GetManifest(w http.ResponseWriter, r *http.Request)
if _, ok := err.(distribution.ErrTagUnknown); ok {
imh.Errors = append(imh.Errors, errcode.ErrorCodeManifestUnknown.WithDetail(err))
} else {
imh.Errors = append(imh.Errors, errcodeErrorsFor(err)...)
imh.Errors = append(imh.Errors, toErrcodeErrors(err)...)
}
return
}
@@ -145,7 +145,7 @@ func (imh *manifestHandler) GetManifest(w http.ResponseWriter, r *http.Request)
if _, ok := err.(distribution.ErrManifestUnknownRevision); ok {
imh.Errors = append(imh.Errors, errcode.ErrorCodeManifestUnknown.WithDetail(err))
} else {
imh.Errors = append(imh.Errors, errcodeErrorsFor(err)...)
imh.Errors = append(imh.Errors, toErrcodeErrors(err)...)
}
return
}