Skip to content

Errors ​

Every rejection is a DoxorError. Check error.code; the original error is in error.cause.

ts
try {
  await 
db
.
users
.
insert
(
user
)
} catch (
error
) {
if (
error
instanceof
DoxorError
&&
error
.
code
=== 'Constraint')
showEmailTaken
()
else throw
error
}

Error codes ​

CodeMeaning
ConstraintThe key or a unique index value already exists.
NotFoundThe collection or index does not exist.
DataNot a valid key, or a required key is missing.
DataCloneThe value cannot be stored (functions, DOM nodes, proxies).
QuotaThe storage quota is exceeded.
ReadOnlyA write in a readonly transaction.
TransactionInactiveThe transaction committed before the work finished (an await on non-IndexedDB work).
OutdatedNewer code upgraded the database; reload before writing.
SchemaConflictAn incompatible schema change without a migration.
MigrationA migration failed, or a previous upgrade did not finish.
VersionThe database kept changing version during an upgrade (concurrent upgrades).
UnavailableNo IndexedDB in this environment (SSR, some private modes).
AbortedThe transaction or open was aborted.
UnknownAnything else; see cause.

The codes are stable, so it is safe to branch on them.

See also: transactions for TransactionInactive, migrations for SchemaConflict and Migration, and multiple tabs for Outdated.

Released under the MIT License.