mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 19:42:30 +08:00
Update ErrRequestErrorBase
from [plugin.downstreamError]
to [plugin.requestFailureError]
(#100965)
* Update ErrRequestErrorBase to make it more clear for developers * Trigger build * requestError -> requestFailureError * Fix test * Update pkg/plugins/backendplugin/grpcplugin/client_v2.go Co-authored-by: Will Browne <wbrowne@users.noreply.github.com> --------- Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
This commit is contained in:
@ -249,7 +249,7 @@ func TestDataSourceQueryError(t *testing.T) {
|
||||
expectedStatus: errutil.StatusInternal.HTTPStatus(),
|
||||
expectedBody: body{
|
||||
Message: "An error occurred within the plugin",
|
||||
MessageId: "plugin.downstreamError",
|
||||
MessageId: "plugin.requestFailureError",
|
||||
StatusCode: 500,
|
||||
},
|
||||
},
|
||||
|
@ -114,7 +114,7 @@ func ValidationFailed(msgID string, opts ...BaseOpt) Base {
|
||||
// msgID should be structured as component.errorBrief, for example
|
||||
//
|
||||
// sqleng.connectionError
|
||||
// plugin.downstreamError
|
||||
// plugin.requestFailureError
|
||||
func Internal(msgID string, opts ...BaseOpt) Base {
|
||||
return NewBase(StatusInternal, msgID, opts...)
|
||||
}
|
||||
|
@ -356,15 +356,14 @@ func handleGrpcStatusError(ctx context.Context, errorSource errstatus.Source, er
|
||||
if innerErr != nil {
|
||||
logger.Error("Could not set downstream error source", "error", innerErr)
|
||||
}
|
||||
return plugins.ErrPluginDownstreamErrorBase.Errorf("%v", err)
|
||||
return plugins.ErrPluginRequestFailureErrorBase.Errorf("%v", err)
|
||||
case backend.ErrorSourcePlugin:
|
||||
errorSourceErr := backend.WithErrorSource(ctx, backend.ErrorSourcePlugin)
|
||||
if errorSourceErr != nil {
|
||||
logger.Error("Could not set plugin error source", "error", errorSourceErr)
|
||||
}
|
||||
// a downstream error is returned here as plugin errors are considered as downstream errors in the
|
||||
// context of the Grafana server.
|
||||
return plugins.ErrPluginDownstreamErrorBase.Errorf("%v", err)
|
||||
// plugin request has failed after being sent from the Grafana server
|
||||
return plugins.ErrPluginRequestFailureErrorBase.Errorf("%v", err)
|
||||
}
|
||||
return fmt.Errorf("%v: %w", "Failed to query data", err)
|
||||
}
|
||||
|
@ -24,9 +24,9 @@ var (
|
||||
errutil.WithPublicMessage("Plugin health check failed"),
|
||||
errutil.WithDownstream())
|
||||
|
||||
// ErrPluginDownstreamErrorBase error returned when a plugin request fails.
|
||||
// Exposed as a base error to wrap it with plugin downstream errors.
|
||||
ErrPluginDownstreamErrorBase = errutil.Internal("plugin.downstreamError",
|
||||
// ErrPluginRequestFailureErrorBase error returned when a plugin request fails.
|
||||
// Exposed as a base error to wrap it with plugin request errors.
|
||||
ErrPluginRequestFailureErrorBase = errutil.Internal("plugin.requestFailureError",
|
||||
errutil.WithPublicMessage("An error occurred within the plugin"),
|
||||
errutil.WithDownstream())
|
||||
|
||||
|
@ -68,7 +68,7 @@ func (s *Service) QueryData(ctx context.Context, req *backend.QueryDataRequest)
|
||||
return nil, plugins.ErrPluginRequestCanceledErrorBase.Errorf("client: query data request canceled: %w", err)
|
||||
}
|
||||
|
||||
return nil, plugins.ErrPluginDownstreamErrorBase.Errorf("client: failed to query data: %w", err)
|
||||
return nil, plugins.ErrPluginRequestFailureErrorBase.Errorf("client: failed to query data: %w", err)
|
||||
}
|
||||
|
||||
for refID, res := range resp.Responses {
|
||||
@ -127,7 +127,7 @@ func (s *Service) CallResource(ctx context.Context, req *backend.CallResourceReq
|
||||
return plugins.ErrPluginRequestCanceledErrorBase.Errorf("client: call resource request canceled: %w", err)
|
||||
}
|
||||
|
||||
return plugins.ErrPluginDownstreamErrorBase.Errorf("client: failed to call resources: %w", err)
|
||||
return plugins.ErrPluginRequestFailureErrorBase.Errorf("client: failed to call resources: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
@ -149,7 +149,7 @@ func (s *Service) CollectMetrics(ctx context.Context, req *backend.CollectMetric
|
||||
return nil, plugins.ErrPluginRequestCanceledErrorBase.Errorf("client: collect metrics request canceled: %w", err)
|
||||
}
|
||||
|
||||
return nil, plugins.ErrPluginDownstreamErrorBase.Errorf("client: failed to collect metrics: %w", err)
|
||||
return nil, plugins.ErrPluginRequestFailureErrorBase.Errorf("client: failed to collect metrics: %w", err)
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
|
@ -38,7 +38,7 @@ func TestQueryData(t *testing.T) {
|
||||
},
|
||||
{
|
||||
err: errors.New("surprise surprise"),
|
||||
expectedError: plugins.ErrPluginDownstreamErrorBase,
|
||||
expectedError: plugins.ErrPluginRequestFailureErrorBase,
|
||||
},
|
||||
{
|
||||
err: context.Canceled,
|
||||
|
Reference in New Issue
Block a user