ReqLLM.Step.Error (ReqLLM v1.0.0)

View Source

Req step that integrates with Splode error handling.

This step converts HTTP error responses to structured ReqLLM.Error exceptions and handles common API error patterns. It processes both regular HTTP errors and API-specific error responses.

Usage

request
|> ReqLLM.Step.Error.attach()

The step handles various HTTP status codes and converts them to appropriate ReqLLM.Error types:

  • 400: Bad Request → API.Request error
  • 401: Unauthorized → API.Request error with authentication context
  • 403: Forbidden → API.Request error with authorization context
  • 404: Not Found → API.Request error
  • 429: Rate Limited → API.Request error with rate limit context
  • 500+: Server Error → API.Request error with server context

Error Structure

All errors include:

  • status - HTTP status code
  • reason - Human-readable error description
  • response_body - Raw API response (if available)
  • request_body - Original request body (if available)
  • cause - Underlying error cause (if available)

Summary

Functions

Attaches the Splode error handling step to a Req request struct.

Types

api_error()

@type api_error() :: %ReqLLM.Error.API.Request{
  __exception__: true,
  bread_crumbs: term(),
  cause: term(),
  class: term(),
  path: term(),
  reason: term(),
  request_body: term(),
  response_body: term(),
  splode: term(),
  stacktrace: term(),
  status: term(),
  vars: term()
}

Functions

attach(req)

@spec attach(Req.Request.t()) :: Req.Request.t()

Attaches the Splode error handling step to a Req request struct.

Parameters

  • req - The Req request struct

Returns

  • Updated Req request struct with the step attached