mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
prometheus: Improve IsAPIError's documentation (#29432)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
parent
b3c4db1d27
commit
107f658229
@ -218,9 +218,9 @@ func parseResponse(value model.Value, query *PrometheusQuery) (*tsdb.QueryResult
|
|||||||
return queryRes, nil
|
return queryRes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsAPIError returns whether err is or wraps a Prometheus error.
|
||||||
func IsAPIError(err error) bool {
|
func IsAPIError(err error) bool {
|
||||||
// Have to use errors.As to compare Prometheus errors, since errors.Is won't work due to Prometheus
|
// Check if the right error type is in err's chain.
|
||||||
// errors being pointers and errors.Is ends up comparing them by pointer address
|
|
||||||
var e *apiv1.Error
|
var e *apiv1.Error
|
||||||
return errors.As(err, &e)
|
return errors.As(err, &e)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user