Skip to Content

Errors

Every error Quickben throws extends QuickbenError. It has a stable code and a suggested HTTP status.

ClasscodestatusThrown when
ValidationErrorVALIDATION400Input, where, sort, select or cursor is invalid.
UnauthorizedErrorUNAUTHORIZED401Access denied and there is no user.
ForbiddenErrorFORBIDDEN403Access denied for the user.
NotFoundErrorNOT_FOUND404Unknown collection, or the document is missing or not readable.
ConflictErrorCONFLICT409A unique value or id is taken. field names the field when known.
ConfigErrorCONFIG500The config is invalid.

Handling errors

import { QuickbenError, ValidationError } from "@quickben/core"; try { await qb.create("posts", { title: "" }, { user }); } catch (error) { if (error instanceof ValidationError) { for (const issue of error.issues) console.log(issue.path, issue.message); } else if (error instanceof QuickbenError) { console.log(error.code, error.status); } else { throw error; } }

ValidationError.issues is a list of { path, message }. path is dot-separated, for example tags.0.

Last updated on