loki: alerting: better error-handling (#44700)

This commit is contained in:
Gábor Farkas 2022-02-01 13:34:03 +01:00 committed by GitHub
parent 22c3d72d9c
commit 3873c5e7b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -99,7 +99,6 @@ func newInstanceSettings(httpClientProvider httpclient.Provider) datasource.Inst
func (s *Service) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
result := backend.NewQueryDataResponse()
queryRes := backend.DataResponse{}
dsInfo, err := s.getDSInfo(req.PluginContext)
if err != nil {
@ -132,10 +131,15 @@ func (s *Service) QueryData(ctx context.Context, req *backend.QueryDataRequest)
defer span.End()
frames, err := runQuery(client, query)
queryRes := backend.DataResponse{}
if err != nil {
return result, err
queryRes.Error = err
} else {
queryRes.Frames = frames
}
queryRes.Frames = frames
result.Responses[query.RefID] = queryRes
}
return result, nil