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:
Ivana Huckova
2025-03-20 18:44:47 +01:00
committed by GitHub
parent 3ef583aa05
commit 307974f20d
4 changed files with 62 additions and 17 deletions

View File

@ -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) {