mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-23 18:55:18 +01:00
Return 404 rather than 500 error when getting registry info
In Harbor 2.0, the replication isn't supported between instances with different versions, this commit returns the 404 error when trying to get the registry info whose version is different with the current one Signed-off-by: Wenkai Yin <yinw@vmware.com>
This commit is contained in:
parent
73f3a305ce
commit
213c534e8a
@ -193,12 +193,11 @@ func (b *BaseAPI) ParseAndHandleError(text string, err error) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
log.Errorf("%s: %v", text, err)
|
||||
if e, ok := err.(*commonhttp.Error); ok {
|
||||
b.RenderError(e.Code, e.Message)
|
||||
b.RenderError(e.Code, fmt.Sprintf("%s: %s", text, e.Message))
|
||||
return
|
||||
}
|
||||
b.SendInternalServerError(errors.New(""))
|
||||
b.SendInternalServerError(fmt.Errorf("%s: %v", text, err))
|
||||
}
|
||||
|
||||
// SendUnAuthorizedError sends unauthorized error to the client.
|
||||
@ -226,7 +225,7 @@ func (b *BaseAPI) SendBadRequestError(err error) {
|
||||
// When you send an internal server error to the client, you expect user to check the log
|
||||
// to find out the root cause.
|
||||
func (b *BaseAPI) SendInternalServerError(err error) {
|
||||
b.RenderError(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError))
|
||||
b.RenderError(http.StatusInternalServerError, err.Error())
|
||||
}
|
||||
|
||||
// SendForbiddenError sends forbidden error to the client.
|
||||
|
@ -416,7 +416,7 @@ func (t *RegistryAPI) GetInfo() {
|
||||
}
|
||||
info, err := adp.Info()
|
||||
if err != nil {
|
||||
t.SendInternalServerError(fmt.Errorf("failed to get registry info %d: %v", id, err))
|
||||
t.ParseAndHandleError(fmt.Sprintf("failed to get registry info %d", id), err)
|
||||
return
|
||||
}
|
||||
// currently, only the local Harbor registry supports the event based trigger, append it here
|
||||
|
Loading…
Reference in New Issue
Block a user