Error Handling
The SDK raises typed exception classes for different failure scenarios, making it simple to handle specific error conditions in your application.
Error Classes
All API errors inherit from the base FellohError class. You can catch the base class or target specific error types.
| Error Class | Status Code | Description |
|---|---|---|
FellohAuthenticationError | 401 | Invalid API credentials or expired token |
FellohForbiddenError | 403 | Insufficient permissions for the requested action |
FellohNotFoundError | 404 | The requested resource does not exist |
FellohValidationError | 422 | Request body failed validation — check errors for field-level details |
FellohRateLimitError | 429 | API rate limit exceeded |
FellohServerError | 5xx | Server error — the SDK automatically retries these |
FellohNetworkError | — | Network failure (timeout, DNS, connection refused) — also retried automatically |
The FellohError Object
Every exception raised by the SDK includes structured data about the failure.
Attributes
- Name
message- Type
- str
- Description
A human-readable error message (also the string representation of the exception).
- Name
status_code- Type
- int
- Description
The HTTP status code.
0for network-level failures.
- Name
errors- Type
- list[dict]
- Description
A list of structured error dicts returned by the API. Each includes
title,message,code,type, anddocumentation_url.
- Name
meta- Type
- dict
- Description
Response metadata including
request_id— useful for debugging with Felloh support.
Error Handling
from felloh import (
FellohError,
FellohNotFoundError,
FellohValidationError,
)
try:
await client.bookings.get("non-existent-id")
except FellohNotFoundError:
print("Booking not found")
except FellohValidationError as e:
# Inspect field-level validation errors
for error in e.errors:
print(f"{error['title']}: {error['message']}")
except FellohError as e:
print(f"Status: {e.status_code}")
print(f"Errors: {e.errors}")
print(f"Request ID: {e.meta.get('request_id')}")
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
from felloh import FellohClient
from felloh.types import FellohConfig
client = FellohClient(FellohConfig(
public_key="your-public-key",
private_key="your-private-key",
max_retries=3, # retry up to 3 times on 5xx/network errors
timeout=15.0, # 15 second timeout per request
))
