Chore: Refactor backend plugin errors (#74928)

This commit is contained in:
Andres Martinez Gotor
2023-09-25 11:56:03 +02:00
committed by GitHub
parent 38d2357bb8
commit 1714fa598c
16 changed files with 102 additions and 130 deletions

View File

@ -20,7 +20,6 @@ import (
"github.com/grafana/grafana/pkg/api/dtos"
"github.com/grafana/grafana/pkg/api/response"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/plugins/backendplugin"
"github.com/grafana/grafana/pkg/plugins/repo"
ac "github.com/grafana/grafana/pkg/services/accesscontrol"
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
@ -492,18 +491,6 @@ func (hs *HTTPServer) UninstallPlugin(c *contextmodel.ReqContext) response.Respo
}
func translatePluginRequestErrorToAPIError(err error) response.Response {
if errors.Is(err, backendplugin.ErrPluginNotRegistered) {
return response.Error(http.StatusNotFound, "Plugin not found", err)
}
if errors.Is(err, backendplugin.ErrMethodNotImplemented) {
return response.Error(http.StatusNotFound, "Not found", err)
}
if errors.Is(err, backendplugin.ErrPluginUnavailable) {
return response.Error(http.StatusServiceUnavailable, "Plugin unavailable", err)
}
return response.ErrOrFallback(http.StatusInternalServerError, "Plugin request failed", err)
}