Documentation
¶
Overview ¶
Package failure owns provider-neutral inference failures shared by codecs, transports, and provider integrations.
Index ¶
- Constants
- type APIError
- func APIErrorFromResponse(status int, body []byte, headers http.Header, retryAfter time.Duration) *APIError
- func NewAPIError(status int, code, requestID string, retryAfter time.Duration) *APIError
- func NewAPIErrorWithStatusText(status int, code, requestID string, retryAfter time.Duration, ...) *APIError
- type ModelMismatchError
- type NetworkError
- type ResponseBodyTooLargeError
Constants ¶
const MaxErrorBodyBytes = 64 << 10
MaxErrorBodyBytes is the maximum transient provider-error prefix parsed by APIErrorFromResponse. No bytes from that prefix are retained in APIError.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct {
Status int
// Code is a provider error code from the closed allowlist below. It is
// intentionally not a free-form provider message.
Code string
// ProviderCode is an additive descriptive alias for Code. Both fields are
// normalized before they are emitted; NewAPIError populates both.
ProviderCode string
// RequestID is copied only from known request-ID headers and only when it
// is bounded and printable. Raw response headers are never retained.
RequestID string
// RetryAfter is the server-advertised wait from a Retry-After header,
// integer-seconds form only. Zero means absent or unparseable.
RetryAfter time.Duration
// contains filtered or unexported fields
}
func APIErrorFromResponse ¶
func APIErrorFromResponse(status int, body []byte, headers http.Header, retryAfter time.Duration) *APIError
APIErrorFromResponse extracts only allowlisted provider codes and request IDs. The body is parsed transiently and is never copied into the returned error. The caller must bound body before calling this helper; this function also truncates defensively for direct callers.
func NewAPIError ¶
NewAPIError constructs an APIError from already-sanitized fields. Raw provider messages, bodies, and headers have no representation in APIError.
func NewAPIErrorWithStatusText ¶
func NewAPIErrorWithStatusText(status int, code, requestID string, retryAfter time.Duration, statusText string) *APIError
NewAPIErrorWithStatusText constructs an APIError with a bounded, gateway-owned status text. Provider response messages must use APIErrorFromResponse instead; arbitrary text is rejected and never stored.
type ModelMismatchError ¶
type ModelMismatchError struct {
BoundProvider model.ProviderName
RequestProvider model.ProviderName
BoundEndpoint string
RequestEndpoint string
BoundAPIFormat model.APIFormat
RequestAPIFormat model.APIFormat
}
func (*ModelMismatchError) Error ¶
func (e *ModelMismatchError) Error() string
type NetworkError ¶
type NetworkError struct {
Err error
}
func (*NetworkError) Error ¶
func (e *NetworkError) Error() string
func (*NetworkError) Unwrap ¶
func (e *NetworkError) Unwrap() error
type ResponseBodyTooLargeError ¶
type ResponseBodyTooLargeError struct{ Limit int }
ResponseBodyTooLargeError reports a bounded response that cannot safely be decoded. It contains only the configured bound.
func (*ResponseBodyTooLargeError) Error ¶
func (e *ResponseBodyTooLargeError) Error() string
func (*ResponseBodyTooLargeError) Format ¶
func (e *ResponseBodyTooLargeError) Format(state fmt.State, _ rune)
func (*ResponseBodyTooLargeError) GoString ¶
func (e *ResponseBodyTooLargeError) GoString() string