claude/types/error

Types

Errors returned by the Anthropic API.

pub type ApiError {
  AuthenticationError(message: String)
  RateLimitError(
    message: String,
    retry_after: option.Option(Int),
  )
  BadRequestError(message: String)
  NotFoundError(message: String)
  ServerError(message: String, status: Int)
  ConnectionError(message: String)
  TimeoutError
  UnknownError(message: String, status: Int)
}

Constructors

  • AuthenticationError(message: String)
  • RateLimitError(message: String, retry_after: option.Option(Int))
  • BadRequestError(message: String)
  • NotFoundError(message: String)
  • ServerError(message: String, status: Int)
  • ConnectionError(message: String)
  • TimeoutError
  • UnknownError(message: String, status: Int)

Values

pub fn from_status(status: Int, body: String) -> ApiError

Map an HTTP status code and response body to an ApiError.

TODO: Parse the Retry-After header for 429 responses. Currently this always sets retry_after: None because only the response body is available here — plumbing the response headers through would require changes to the HTTP handling layer.

Search Document