Documentation
¶
Overview ¶
Package normalize provides shared provider error normalization helpers.
Index ¶
- func DecodeError(provider string, err error) error
- func DecodeErrorWithBody(provider string, err error, body []byte) error
- func NetworkError(provider string, err error) error
- func OpenAIStyleProviderError(provider string, status int, body []byte, requestID string) error
- func ProviderError(provider string, status int, requestID, code, message string, sentinel error) error
- func RequireAPIKey(provider string, key core.Secret) error
- func SentinelForStatus(status int) error
- func SentinelForStatusWithOverrides(status int, overrides map[int]error) error
- func WithRetryAfter(err error, headers ...http.Header) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeError ¶
DecodeError wraps decode/parsing failures as provider-specific decode errors.
func DecodeErrorWithBody ¶ added in v0.16.0
DecodeErrorWithBody wraps decode/parsing failures as provider-specific decode errors, additionally preserving the raw response body (truncated) that failed to decode so callers can inspect what the provider actually sent back.
func NetworkError ¶
NetworkError wraps transport failures as provider-specific network errors.
func OpenAIStyleProviderError ¶
OpenAIStyleProviderError normalizes providers that use OpenAI-style error envelopes.
func ProviderError ¶
func ProviderError(provider string, status int, requestID, code, message string, sentinel error) error
ProviderError constructs a normalized ProviderError. If message is empty, HTTP status text is used. If sentinel is nil, default status-based mapping is applied.
func RequireAPIKey ¶ added in v0.17.0
RequireAPIKey returns a descriptive *core.ProviderError wrapping core.ErrUnauthorized when the API key is empty (or whitespace-only), so a provider can fail fast before making an unauthenticated request. Returns nil when the key is present.
func SentinelForStatus ¶
SentinelForStatus maps an HTTP status code to a core sentinel error.
func SentinelForStatusWithOverrides ¶
SentinelForStatusWithOverrides maps an HTTP status code to a core sentinel error, then applies any exact status overrides from the provided map.
Types ¶
This section is empty.