Documentation
¶
Overview ¶
Package apierror holds the SDK's error model: the wire-error mapping and the typed error hierarchy returned to callers. It is re-exported by the bird package (bird.APIError, bird.RateLimitError, …), so these names are the semver-locked public surface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromResponse ¶
FromResponse turns a terminal non-2xx response into a typed error. It is the single place a wire error becomes a Go error. The API wraps errors as {"error": {...}}; a bare top-level body and a non-JSON body are both tolerated.
Types ¶
type APIError ¶
type APIError struct {
StatusCode int
Type ErrorType
// Code is the stable, opaque error code (E#####).
Code string
// Name is a human-readable slug for logs; paired with Code, never replaces it.
Name string
// Message is the human-readable description.
Message string
// DocURL links to the documentation for this Code.
DocURL string
// RequestID correlates with the X-Request-Id response header.
RequestID string
// Param is the offending field, when applicable.
Param string
// VendorCode is a verbatim code from a downstream system (SMTP reply, decline).
VendorCode string
}
APIError is the error the server returned. It is the base for every API failure; catch it with errors.As to handle any server error uniformly.
type ConnectionError ¶
type ConnectionError struct{ Err error }
ConnectionError is a network-level failure with no HTTP response (DNS, connection refused, socket hangup).
func (*ConnectionError) Error ¶
func (e *ConnectionError) Error() string
func (*ConnectionError) Unwrap ¶
func (e *ConnectionError) Unwrap() error
type ErrorDetail ¶
type ErrorDetail struct {
// Param is the dotted field path, e.g. "to[0]", "subject".
Param string `json:"param"`
// Message is what is wrong with this field.
Message string `json:"message"`
}
ErrorDetail is one per-field validation failure.
type ErrorType ¶
type ErrorType string
ErrorType is the coarse error category clients branch on (ADR-0016). Branch on APIError.Type for the flat categories, or use errors.As for the variants that carry extra data (RateLimitError, ValidationError).
const ( ErrorTypeBadRequest ErrorType = "bad_request_error" ErrorTypeAuth ErrorType = "auth_error" ErrorTypeBilling ErrorType = "billing_error" ErrorTypePermission ErrorType = "permission_error" ErrorTypeNotFound ErrorType = "not_found_error" ErrorTypeConflict ErrorType = "conflict_error" ErrorTypePrecondition ErrorType = "precondition_error" ErrorTypePayloadTooLarge ErrorType = "payload_too_large_error" ErrorTypeMisdirected ErrorType = "misdirected_error" ErrorTypeValidation ErrorType = "validation_error" ErrorTypeRateLimit ErrorType = "rate_limit_error" ErrorTypeInternal ErrorType = "internal_error" ErrorTypeNotImplemented ErrorType = "not_implemented_error" )
type RateLimitError ¶
RateLimitError is a 429. RetryAfter is the server-advised wait, or zero when none was advised.
func (*RateLimitError) Unwrap ¶
func (e *RateLimitError) Unwrap() error
type TimeoutError ¶
TimeoutError means a single attempt exceeded its per-attempt timeout.
func (*TimeoutError) Error ¶
func (e *TimeoutError) Error() string
type ValidationError ¶
type ValidationError struct {
*APIError
Details []ErrorDetail
}
ValidationError is a 422; Details carries the per-field failures.
func (*ValidationError) Unwrap ¶
func (e *ValidationError) Unwrap() error
type WebhookVerificationError ¶
type WebhookVerificationError struct{ Reason string }
WebhookVerificationError means a webhook payload failed signature verification (bad signature, stale timestamp, malformed headers).
func (*WebhookVerificationError) Error ¶
func (e *WebhookVerificationError) Error() string