class

AI::Provider::APICallError

Inherits AI::Provider::AISDKError < Exception < Reference < Object

Error thrown when an API call fails.

This error captures detailed information about the failed API request including URL, request body, response details, and retry eligibility.

Constructors

new(*, message : String, url : String, request_body_values, status_code : Int32 | Nil = nil, response_headers : Hash(String, String) | Nil = nil, response_body : String | Nil = nil, cause : Exception | Nil = nil, is_retryable : Bool | Nil = nil, data = nil)

Creates a new APICallError.

Parameters:

  • message: The error message
  • url: The URL that was called
  • request_body_values: The request body values (any JSON-serializable type)
  • status_code: Optional HTTP status code
  • response_headers: Optional response headers
  • response_body: Optional response body
  • cause: Optional underlying exception
  • is_retryable: Whether the request can be retried (auto-computed if not provided)
  • data: Optional additional error data
Source

Class methods

instance?(error) : Bool

Checks if the given value is an instance of APICallError.

Source

Instance methods

data

Additional data associated with the error.

Source
request_body_values

The request body values that were sent. Stored as JSON::Any to handle any JSON-serializable type.

Source
response_body

The response body as a string, if available.

Source
response_headers

The response headers, if available.

Source
retryable?

Whether this error is eligible for retry.

Source
status_code

The HTTP status code of the response, if available.

Source
url

The URL that was called.

Source