errors library
Typed error hierarchy for CocoBase SDK.
All SDK errors extend CocobaseError, so you can catch specific types:
try {
await db.getDocument('posts', 'bad-id');
} catch (e) {
if (e is NotFoundError) {
showNotFound();
} else if (e is UnauthorizedError) {
redirectToLogin();
} else if (e is RateLimitError) {
showRetryMessage();
}
}
Functions
-
createHttpError(
{required int statusCode, required String url, required String method, required dynamic detail, required String suggestion}) → CocobaseError - Factory that maps HTTP status codes to typed error classes.