Alerting: Add QueryError to expr package (#41737)

This commit is contained in:
George Robinson
2021-11-16 13:42:22 +00:00
committed by GitHub
parent 15d6da8e8c
commit 543b1a7e39
2 changed files with 26 additions and 1 deletions

View File

@ -19,6 +19,15 @@ var (
logger = log.New("expr")
)
type QueryError struct {
RefID string
Err error
}
func (e QueryError) Error() string {
return fmt.Sprintf("failed to execute query %s: %s", e.RefID, e.Err)
}
// baseNode includes common properties used across DPNodes.
type baseNode struct {
id int64
@ -240,7 +249,7 @@ func (dn *DSNode) Execute(ctx context.Context, vars mathexp.Vars, s *Service) (m
vals := make([]mathexp.Value, 0)
for refID, qr := range resp.Responses {
if qr.Error != nil {
return mathexp.Results{}, fmt.Errorf("failed to execute query %v: %w", refID, qr.Error)
return mathexp.Results{}, QueryError{RefID: refID, Err: qr.Error}
}
if len(qr.Frames) == 1 {