Error Handling
The SDK raises typed error classes for different failure scenarios, making it simple to handle specific error conditions in your application.
Error Classes
All API errors extend the base Felloh::Error class. You can rescue the base class or target specific error types.
| Error Class | Status Code | Description |
|---|---|---|
Felloh::AuthenticationError | 401 | Invalid API credentials or expired token |
Felloh::ForbiddenError | 403 | Insufficient permissions for the requested action |
Felloh::NotFoundError | 404 | The requested resource does not exist |
Felloh::ValidationError | 422 | Request body failed validation — check errors for field-level details |
Felloh::RateLimitError | 429 | API rate limit exceeded |
Felloh::ServerError | 5xx | Server error — the SDK automatically retries these |
Felloh::NetworkError | — | Network failure (timeout, DNS, connection refused) — also retried automatically |
The Error Object
Every error raised by the SDK includes structured data about the failure.
Properties
- Name
message- Type
- String
- Description
A human-readable error message.
- Name
status_code- Type
- Integer
- Description
The HTTP status code.
nilfor network-level failures.
- Name
errors- Type
- Array
- Description
An array of structured error hashes returned by the API. Each includes
title,message,code,type, anddocumentation_url.
- Name
meta- Type
- Hash
- Description
Response metadata including
request_id— useful for debugging with Felloh support.
Error Handling
begin
client.bookings.get("non-existent-id")
rescue Felloh::NotFoundError => e
puts "Booking not found"
rescue Felloh::ValidationError => e
# Inspect field-level validation errors
e.errors.each do |error|
puts "#{error['title']}: #{error['message']}"
end
rescue Felloh::Error => e
puts e.status_code # HTTP status code
puts e.errors # API error details
puts e.meta # Includes request_id
end
Automatic Retries
The SDK automatically retries requests that fail with a 5xx server error or a network error. Retries use exponential backoff
with a maximum of max_retries attempts (default: 2).
You can configure this when creating the client:
Configuring Retries
client = Felloh::Client.new(
public_key: "your-public-key",
private_key: "your-private-key",
max_retries: 3, # retry up to 3 times
timeout: 15, # 15 second timeout per request
)
