Skip to content

DbError ​

DbError is the structured error type for recoverable database failures.

Signatureinterface DbError { readonly code: string; readonly message: string }

Fields ​

FieldTypePurpose
codestringStable identifier for programmatic handling, such as ERR_DB_QUERY_FAILED.
messagestringHuman-readable explanation of the failure.

Database operations return Promise<Result<T, DbError>>. Await each call to receive the Result, then handle failures with onfail, ?, or pattern matching. The tyrus:db API does not use throws.

Runtime codes ​

CodeMeaning
ERR_DB_CONNECTION_FAILEDThe configured database backend could not be connected.
ERR_DB_CONNECTION_TIMEOUTThe PostgreSQL, MySQL, or MongoDB connection attempt exceeded connectTimeoutMs.
ERR_DB_POOL_TIMEOUTA PostgreSQL or MySQL pool connection, or a MongoDB runtime operation slot, was unavailable before acquireTimeoutMs.
ERR_DB_QUERY_TIMEOUTA PostgreSQL, MySQL, or MongoDB database operation exceeded queryTimeoutMs.
ERR_DB_BUSYThe bounded database worker queue already contains 128 pending requests.
ERR_DB_CONNECTION_CONFIGURATIONThe environment variable named by database.connectionEnv is missing.
ERR_DB_INVALID_CONFIGURATIONThe runtime database target is malformed or does not match a supported configuration.
ERR_DB_INVALID_CONNECTIONThe connection variable does not contain a valid backend URL or URI. The connection value is never included in the error message.
ERR_DB_TLS_CONFIGURATIONA configured database TLS file conflicts with the connection URL or does not allow certificate and hostname verification.
ERR_DB_BACKEND_UNAVAILABLEThe configured backend does not have a runtime driver in this build.
ERR_DB_INVALID_SQLSQL could not be prepared for the configured backend.
ERR_DB_FEATURE_UNSUPPORTEDThe configured backend does not support the requested database feature.
ERR_DB_SQLITE_BUSYSQLite could not acquire the required lock before the timeout.
ERR_DB_SQLITE_CONSTRAINTA database constraint rejected the change.
ERR_DB_EXECUTE_FAILEDThe configured database backend rejected or could not execute the statement.
ERR_DB_INVALID_PARAMETERSParameters could not be encoded as supported database values.
ERR_DB_PARAMETER_LIMITA statement attempted to bind more than 999 parameters.
ERR_DB_DECODE_FAILEDThe database returned a value that could not be decoded to a supported type.
ERR_DB_VALUE_OUT_OF_RANGEA value could not be represented by the target database type.
ERR_DB_DOCUMENT_TOO_LARGEA serialized MongoDB BSON document or filter exceeds 16 MiB.
ERR_DB_VALUE_TOO_DEEPA MongoDB structured value exceeds 100 nested levels.
ERR_DB_INVALID_TEMPORAL_VALUEA MongoDB Instant has invalid seconds or nanoseconds fields.
ERR_DB_INVALID_MODEL_VALUEA MongoDB Model value is missing a required field or does not match its declared field type.