Errors
Error classes
All errors extend CtrodbError, which extends Error.
import {
CtrodbError,
ConnectionError,
CollectionNotFoundError,
RecordNotFoundError,
SchemaError,
ValidationError,
QueryError,
} from "ctrodb"
CtrodbError
Base error class. Sets this.name = "CtrodbError".
ConnectionError
Thrown when operations are attempted before connecting.
new ConnectionError(dbName, reason?)
// "Failed to connect to database "foo": reason"
// or "Database "foo" is not connected. Call db.connect()..."
SchemaError
Thrown when schema configuration is invalid.
new SchemaError(message)
// Invalid schema configuration.
ValidationError
Thrown when a record violates field validation rules.
new ValidationError(collection, field, message, value?)
// 'Field "email" in collection "users": is required.'
Has .field, .collection, .value properties.
Additional classes (not thrown by ctrodb)
These error classes are exported for use in your own code or plugins:
new CollectionNotFoundError(name, availableCollections?)
// 'Collection "users" not found. Available collections: todos, posts'
new RecordNotFoundError(collection, id)
// 'Record with id "42" not found in collection "todos".'
new QueryError(message)
// Query execution error.How is this guide?
Last updated on Jun 20, 2026