mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 07:52:21 +08:00
Chore: Refactor backend plugin errors (#74928)
This commit is contained in:

committed by
GitHub

parent
38d2357bb8
commit
1714fa598c
@ -11,7 +11,6 @@ import (
|
||||
|
||||
"github.com/grafana/grafana/pkg/api/response"
|
||||
"github.com/grafana/grafana/pkg/middleware/requestmeta"
|
||||
"github.com/grafana/grafana/pkg/plugins/backendplugin"
|
||||
"github.com/grafana/grafana/pkg/plugins/httpresponsesender"
|
||||
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
@ -125,16 +124,6 @@ func (hs *HTTPServer) makePluginResourceRequest(w http.ResponseWriter, req *http
|
||||
}
|
||||
|
||||
func handleCallResourceError(err error, reqCtx *contextmodel.ReqContext) {
|
||||
if errors.Is(err, backendplugin.ErrPluginUnavailable) {
|
||||
reqCtx.JsonApiErr(http.StatusServiceUnavailable, "Plugin unavailable", err)
|
||||
return
|
||||
}
|
||||
|
||||
if errors.Is(err, backendplugin.ErrMethodNotImplemented) {
|
||||
reqCtx.JsonApiErr(http.StatusNotFound, "Not found", err)
|
||||
return
|
||||
}
|
||||
|
||||
resp := response.ErrOrFallback(http.StatusInternalServerError, "Failed to call resource", err)
|
||||
resp.WriteTo(reqCtx)
|
||||
}
|
||||
|
Reference in New Issue
Block a user