queryerror

package
v0.2.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Datasource  string
	Operation   string
	StatusCode  int
	Message     string
	ErrorSource string
}

APIError is a typed error for datasource query endpoints.

It preserves the datasource type, operation, HTTP status, and the human message extracted from Grafana or downstream datasource responses so the fail package can render a useful error instead of dumping raw JSON.

func FromBody

func FromBody(datasource, operation string, statusCode int, body []byte) *APIError

FromBody constructs an APIError by extracting the most useful message from an HTTP response body. It understands Grafana's datasource query envelope as well as common {"error": ...} / {"message": ...} JSON responses.

The embedded `results.*.status` from the Grafana query envelope is only used as a fallback when the transport status is 2xx — i.e., to surface query-level failures hiding inside a 200 OK. When the transport status is already an error (4xx/5xx), it is kept as the authoritative signal so auth, proxy, and gateway failures are not misclassified by downstream-supplied status codes.

func New

func New(datasource, operation string, statusCode int, message, errorSource string) *APIError

New constructs an APIError with sanitized message fields.

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) IsParseError

func (e *APIError) IsParseError() bool

IsParseError reports whether the datasource returned a syntax/parse error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL