mirror of
https://github.com/grafana/grafana.git
synced 2025-09-27 12:14:08 +08:00
Data sources: Improve error messages for grpc errors (#102372)
* Data sources: Improve error messages for grpc errors * Improve code comments * Fix lint * Update connection issue message * Update name * Update comment * Update, rename and add test * Update, remove POC change * Fix lint
This commit is contained in:
@ -30,6 +30,14 @@ var (
|
||||
errNilSender = errors.New("sender cannot be nil")
|
||||
)
|
||||
|
||||
// passthroughErrors contains a list of errors that should be returned directly to the caller without wrapping
|
||||
var passthroughErrors = []error{
|
||||
plugins.ErrPluginUnavailable,
|
||||
plugins.ErrMethodNotImplemented,
|
||||
plugins.ErrPluginGrpcResourceExhaustedBase,
|
||||
plugins.ErrPluginGrpcConnectionUnavailableBase,
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
pluginRegistry registry.Service
|
||||
}
|
||||
@ -52,12 +60,10 @@ func (s *Service) QueryData(ctx context.Context, req *backend.QueryDataRequest)
|
||||
|
||||
resp, err := p.QueryData(ctx, req)
|
||||
if err != nil {
|
||||
if errors.Is(err, plugins.ErrMethodNotImplemented) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if errors.Is(err, plugins.ErrPluginUnavailable) {
|
||||
return nil, err
|
||||
for _, e := range passthroughErrors {
|
||||
if errors.Is(err, e) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
if errors.Is(err, context.Canceled) {
|
||||
|
Reference in New Issue
Block a user