Error Handling
The SDK throws typed exception classes for different failure scenarios, making it simple to handle specific error conditions in your application.
Error Classes
All API errors extend 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 thrown by the SDK includes structured data about the failure.
Properties
- Name
message- Type
- string
- Description
A human-readable error message (via
getMessage()).
- Name
statusCode- Type
- int
- Description
The HTTP status code.
0for network-level failures.
- Name
errors- Type
- array
- Description
An array of structured error arrays returned by the API. Each includes
title,message,code,type, anddocumentation_url.
- Name
meta- Type
- array
- Description
Response metadata including
request_id— useful for debugging with Felloh support.
Error Handling
use Felloh\Exceptions\FellohError;
use Felloh\Exceptions\FellohNotFoundError;
use Felloh\Exceptions\FellohValidationError;
try {
$client->bookings->get('non-existent-id');
} catch (FellohNotFoundError $e) {
echo "Booking not found\n";
} catch (FellohValidationError $e) {
// Inspect field-level validation errors
foreach ($e->errors as $error) {
echo "{$error['title']}: {$error['message']}\n";
}
} catch (FellohError $e) {
echo "Status: {$e->statusCode}\n";
print_r($e->errors);
echo "Request ID: {$e->meta['request_id']}\n";
}
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 maxRetries attempts (default: 2).
You can configure this when creating the client:
Configuring Retries
use Felloh\FellohClient;
use Felloh\FellohConfig;
$client = new FellohClient(new FellohConfig(
publicKey: 'your-public-key',
privateKey: 'your-private-key',
maxRetries: 3, // retry up to 3 times on 5xx/network errors
timeout: 15.0, // 15 second timeout per request
));
