Contribute: Add error source section to errors documentation (#75462)

This commit is contained in:
Marcus Efraimsson 2023-09-26 17:44:36 +02:00 committed by GitHub
parent 1867fc5cee
commit 896b12d422
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -105,6 +105,18 @@ unfortunately not readily available on pkg.go.dev because Grafana is not
fully Go modules compatible, but can be viewed using
[godoc](https://go.dev/cmd/godoc/) from the Grafana directory.
### Error source
You can optionally specify an error source that describes from where an
error originates. By default it's _server_ and means the error originates
from within the application, e.g. Grafana. The `errutil.WithDownstream()`
option may be appended to the NewBase function call to denote an error
originates from a _downstream_ server/service. The error source information
is used in the API layer to distinguish between Grafana errors and
non-Grafana errors to include this information when instrumenting the
application and by that allowing Grafana operators to define SLO's
based on actual Grafana errors.
### Handling errors in the API
API handlers use the `github.com/grafana/grafana/pkg/api/response.Err`