Skip to documentation
Documentation navigation

Documentation navigation

Documentation / guides

Typed errors

Inspect bounded typed failures without retaining provider bodies or caller secrets.

developer

The public error types carry a bounded classification and unwrap only safe causes. Provider response bodies, authorization headers, and arbitrary model output are not retained in the shared failure values.

Families

FamilyTypes
requestModelMismatchError, InvalidTransientMessagesError, structured-output validation/conflict errors
transportRequestBuildError, NetworkError, APIError, ResponseBodyTooLargeError
codecUnsupportedBlockError, UnsupportedConversationError, dialect decode errors
streamStreamReaderError, StreamResultError, dialect StreamAPIError
gatewayroute, authentication, concurrency, and upstream invocation errors

failure.APIError retains only a valid status, a bounded gateway-owned status text, an allowlisted provider code, a bounded request ID, and an integer-second retry delay. NetworkError wraps the underlying network cause. Gateway HTTP writers classify recognized gateway errors and pass native codec errors to the codec that produced them.

Inspection

var apiErr *failure.APIError
if errors.As(err, &apiErr) {
	fmt.Println(apiErr.Status, apiErr.Code, apiErr.RetryAfter)
}
if errors.Is(err, context.Canceled) {
	return err
}

Source and proof

Run go test ./failure ./gateway.

← back to documentation