Dart SDK - Errors#
Every failure throws a RafikiDBError.
Fields#
| Field | Type | Example |
|---|---|---|
message | String | "invalid credentials" |
status | int | 401 |
code | RafikiDBErrorCode | RafikiDBErrorCode.unauthorized |
errors | List<String> | ["Email is required"] |
RafikiDBErrorCode is derived from the HTTP status and is one of:
invalidInput, unauthorized, forbidden, notFound, conflict,
quotaExceeded, internalError.
Handling#
try {
await db.from('profiles').insert({});
} on RafikiDBError catch (error) {
print('${error.status} ${error.code.name}: $error.message');
print(error.errors);
}
DARTCommon codes#
| Code | HTTP | Meaning |
|---|---|---|
invalidInput | 400 | Malformed body, missing/invalid field |
unauthorized | 401 | Missing or invalid key / JWT |
forbidden | 403 | Authenticated but not allowed (scope, RLS) |
notFound | 404 | Resource or table does not exist |
conflict | 409 | Duplicate email/phone, conflicting state |
quotaExceeded | 429 | Plan request limit reached |
internalError | 500 | Server error |
See Error codes for the REST reference.