Commit 107f6582 by Arve Knudsen Committed by GitHub

prometheus: Improve IsAPIError's documentation (#29432)

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
parent b3c4db1d
......@@ -218,9 +218,9 @@ func parseResponse(value model.Value, query *PrometheusQuery) (*tsdb.QueryResult
return queryRes, nil
}
// IsAPIError returns whether err is or wraps a Prometheus error.
func IsAPIError(err error) bool {
// Have to use errors.As to compare Prometheus errors, since errors.Is won't work due to Prometheus
// errors being pointers and errors.Is ends up comparing them by pointer address
// Check if the right error type is in err's chain.
var e *apiv1.Error
return errors.As(err, &e)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment