class AI::Provider::APICallError

Overview

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.

Defined in:

ai/provider/errors/api_call_error.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class AI::Provider::AISDKError

name : String name, to_s(io : IO) : Nil to_s

Constructor methods inherited from class AI::Provider::AISDKError

new(*, name : String, message : String, cause : Exception | Nil = nil) new

Class methods inherited from class AI::Provider::AISDKError

instance?(error) : Bool instance?

Constructor Detail

def self.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

[View source]

Class Method Detail

def self.instance?(error) : Bool #

Checks if the given value is an instance of APICallError.


[View source]

Instance Method Detail

def data : JSON::Any | Nil #

Additional data associated with the error.


[View source]
def request_body_values : JSON::Any | Nil #

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


[View source]
def response_body : String | Nil #

The response body as a string, if available.


[View source]
def response_headers : Hash(String, String) | Nil #

The response headers, if available.


[View source]
def retryable? : Bool #

Whether this error is eligible for retry.


[View source]
def status_code : Int32 | Nil #

The HTTP status code of the response, if available.


[View source]
def url : String #

The URL that was called.


[View source]