mirror of
https://github.com/grafana/grafana.git
synced 2025-07-28 07:02:22 +08:00
Chore: use errutil for pluginRepo errors (#78647)
* Chore: use errutil for pluginRepo errors * Update pkg/util/errutil/status.go * Use errutil helper functions Co-Authored-By: Marcus Efraimsson <marcus.efraimsson@gmail.com> * Forgot the log level * Use entity --------- Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
This commit is contained in:
@ -449,14 +449,6 @@ func (hs *HTTPServer) InstallPlugin(c *contextmodel.ReqContext) response.Respons
|
||||
if errors.As(err, &dupeErr) {
|
||||
return response.Error(http.StatusConflict, "Plugin already installed", err)
|
||||
}
|
||||
var versionUnsupportedErr repo.ErrVersionUnsupported
|
||||
if errors.As(err, &versionUnsupportedErr) {
|
||||
return response.Error(http.StatusConflict, "Plugin version not supported", err)
|
||||
}
|
||||
var versionNotFoundErr repo.ErrVersionNotFound
|
||||
if errors.As(err, &versionNotFoundErr) {
|
||||
return response.Error(http.StatusNotFound, "Plugin version not found", err)
|
||||
}
|
||||
var clientError repo.ErrResponse4xx
|
||||
if errors.As(err, &clientError) {
|
||||
return response.Error(clientError.StatusCode(), clientError.Message(), err)
|
||||
@ -464,12 +456,8 @@ func (hs *HTTPServer) InstallPlugin(c *contextmodel.ReqContext) response.Respons
|
||||
if errors.Is(err, plugins.ErrInstallCorePlugin) {
|
||||
return response.Error(http.StatusForbidden, "Cannot install or change a Core plugin", err)
|
||||
}
|
||||
var archError repo.ErrArcNotFound
|
||||
if errors.As(err, &archError) {
|
||||
return response.Error(http.StatusNotFound, archError.Error(), nil)
|
||||
}
|
||||
|
||||
return response.Error(http.StatusInternalServerError, "Failed to install plugin", err)
|
||||
return response.ErrOrFallback(http.StatusInternalServerError, "Failed to install plugin", err)
|
||||
}
|
||||
|
||||
if hs.Features.IsEnabled(c.Req.Context(), featuremgmt.FlagExternalServiceAccounts) {
|
||||
|
Reference in New Issue
Block a user