mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 04:17:55 +08:00
feat(routes): better error message in case of missing annotations (#1150)
putting this info into error detail would be ideal, but skopeo doesn't print them, so overwrite the error message. Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>
This commit is contained in:
@@ -11,6 +11,12 @@ type Error struct {
|
||||
Detail interface{} `json:"detail,omitempty"`
|
||||
}
|
||||
|
||||
func (e Error) WithMessage(msg string) Error {
|
||||
e.Message = msg
|
||||
|
||||
return e
|
||||
}
|
||||
|
||||
type ErrorList struct {
|
||||
Errors []*Error `json:"errors"`
|
||||
}
|
||||
|
||||
+1
-1
@@ -587,7 +587,7 @@ func (rh *RouteHandler) UpdateManifest(response http.ResponseWriter, request *ht
|
||||
NewErrorList(NewError(INVALID_INDEX, map[string]string{"name": name})))
|
||||
} else if errors.Is(err, zerr.ErrImageLintAnnotations) {
|
||||
WriteJSON(response, http.StatusBadRequest,
|
||||
NewErrorList(NewError(MANIFEST_INVALID, map[string]string{"reference": reference})))
|
||||
NewErrorList(NewError(MANIFEST_INVALID, map[string]string{"reference": reference}).WithMessage(err.Error())))
|
||||
} else {
|
||||
// could be syscall.EMFILE (Err:0x18 too many opened files), etc
|
||||
rh.c.Log.Error().Err(err).Msg("unexpected error: performing cleanup")
|
||||
|
||||
Reference in New Issue
Block a user