PHP SDK - Errors#
Every failure throws a RafikiDBException.
Fields#
| Field | Type | Example |
|---|---|---|
getMessage() | string | "invalid credentials" |
status | int | 401 |
errorCode | string | "unauthorized" |
errors | array | ["Email is required"] |
errorCode is derived from the HTTP status: unauthorized, forbidden,
not_found, conflict, invalid_input, quota_exceeded, internal_error.
Handling#
use RafikiDB\RafikiDBException;
try {
$db->from('profiles')->insert([]);
} catch (RafikiDBException $e) {
$e->getMessage(); // "Nationality is required"
$e->status; // 400
$e->errorCode; // "invalid_input"
$e->errors; // ["Nationality is required"]
}
PHPConnection failures are thrown with status = 0 and a
"Connection error: ..." message.
Common codes#
| Code | HTTP | Meaning |
|---|---|---|
invalid_input | 400 | Malformed body, missing/invalid field |
unauthorized | 401 | Missing or invalid key / JWT |
forbidden | 403 | Authenticated but not allowed (scope, RLS) |
not_found | 404 | Resource or table does not exist |
conflict | 409 | Duplicate email/phone, conflicting state |
quota_exceeded | 429 | Plan request limit reached |
internal_error | 500 | Server error |
See Error codes for the REST reference.