Public declaration syntax from forge-rs/crates/forge-provider-anthropic/src/error.rs Original source SHA-256: 4384a7d539bf316a65bc264cc7d9eb5cf44bb773faed60a6b236c74496f934b2 Function bodies and constant values are omitted. This is not the complete implementation. Source line 23 #[derive(Debug, Error)] pub enum AnthropicError { /// The API returned an HTTP error status code. /// /// Anthropic returns structured error bodies; the `error_type` and `message` /// fields come from the API response. #[error( "Anthropic API returned HTTP {status_code}: type='{error_type}', message='{message}' \ (model='{model}', request_id='{request_id}')" )] ApiError { /// The HTTP status code (e.g., 400, 401, 429, 500). status_code: u16, /// The Anthropic error type (e.g., "invalid_request_error", "authentication_error"). error_type: String, /// Human-readable error message from the API. message: String, /// The model that was being called. model: String, /// The request ID from the `request-id` response header, or "unknown". request_id: String, }, /// An HTTP transport error occurred (DNS failure, connection reset, TLS error). #[error("HTTP transport error calling Anthropic API at '{url}': {reason}")] HttpTransport { /// The URL that was being called. url: String, /// Description of the transport failure. reason: String, }, /// The API response body could not be deserialized. #[error( "failed to deserialize Anthropic API response for model '{model}': {reason} \ (response snippet: '{snippet}')" )] DeserializationFailed { /// The model that produced the response. model: String, /// What went wrong during deserialization. reason: String, /// First 200 bytes of the response body for debugging. snippet: String, }, /// Request serialization failed. #[error("failed to serialize request for Anthropic model '{model}': {reason}")] SerializationFailed { /// The model the request was for. model: String, /// What went wrong during serialization. reason: String, }, /// An SSE stream event could not be parsed. #[error("SSE parse error on event '{event_type}': {reason} (data snippet: '{snippet}')")] SseParseFailed { /// The SSE event type (e.g., "content_block_delta"). event_type: String, /// What went wrong. reason: String, /// First 200 bytes of the data field for debugging. snippet: String, }, /// The request timed out. #[error( "Anthropic API request timed out after {timeout_seconds}s for model '{model}' \ — consider increasing timeout or reducing max_tokens" )] Timeout { /// The model being called. model: String, /// The timeout that was exceeded, in seconds. timeout_seconds: u64, }, /// All retry attempts were exhausted. #[error( "Anthropic API request failed after {attempts} attempts for model '{model}': {last_error}" )] RetriesExhausted { /// The model being called. model: String, /// How many attempts were made. attempts: u32, /// The last error message. last_error: String, }, /// The configuration is invalid. #[error("invalid Anthropic configuration: {reason}")] InvalidConfig { /// What is wrong with the configuration. reason: String, }, }