Every error Bounda throws extends BoundaError, exported from @bounda-dev/core, and carries a
code that stays the same across versions. Branch on code, or on the class where it is
exported; the message is for people and can change.
import { BoundaError } from "@bounda-dev/core";
try { await app.commands.placeOrder(payload);} catch (error) { if (error instanceof BoundaError && error.code === "VALIDATION_FAILED") { // show the issues } throw error;}Terminal means a policy, process or scheduled command that fails with it becomes a dead letter
at once, with errorType: "terminal", since it would fail the same way again. Anything else is
retried by the retry settings and, when they run out, becomes a
dead letter with errorType: "retriable_exhausted".
DOMAIN_ERROR(DomainError; terminal). A command handler rejected withreject(code).rejectedholds the code.app.commandsthrows it; a reaction gets it as a value instead.FOREIGN_REJECTION(no exported class; terminal). A command handler let through aDomainErrorit did not make with its ownreject, such as one rethrown from another app’s command. The command fails rather than rejects, soapp.commandsand a reaction both get this error, never the other command’s code.causeis thatDomainError.VALIDATION_FAILED(ValidationError; terminal). A payload, a duration, a returned process state, theafterandlimitof a read of the global stream, the actor given toas, or whatredactwas given, an event the store does not hold, that does not name the person, or a field its type does not markpersonal, did not validate.issueslists each problem with itspath.CONCURRENCY_CONFLICT(ConcurrencyError; retried). An append found the stream at another version, or, with both versions equal, a person whose personal data the command loaded, or whose fields its events seal, was forgotten before the append committed, whether or not they hold a new key by then; afterruntime.commands.concurrencyRetriesruns of the command. Also a call to a port that tells a recipient of data whose person was forgotten, restricted, lifted or redacted since it was read, before the port is reached, itsstreamIdthe person’s streambounda:<personId>; and an export of a person forgotten, restricted, lifted or redacted while it read, once it has read everything, which an export started again reads as they are then.streamId,expectedVersion,actualVersion.TENANT_FORGOTTEN(TenantForgottenError). The app’s tenant was forgotten: every command, query, export and other call of its app rejects with it, here or on any instance once it has seen the forgetting, and the app runs no reaction any more, but the notices to the tenant’s recipients.tenant,forgottenAt.TENANT_FROZEN(TenantFrozenError). The app’s tenant is frozen: every write of it, on any instance, however long ago it last read the tenant, is refused and keeps nothing of it, untilunfreezeTenant; reads go on. The same write goes through once the freeze is lifted; the background work waits meanwhile rather than failing, and delivers its own then.tenant,frozenAt.HANDLER_TIMEOUT(no exported class; retried). A command, policy or process handler ran out of time (runtime.commands.timeout,runtime.policies.timeout,runtime.processes.handlerTimeout).REACTION_ABANDONED(no exported class; the run already failed). A command a reaction dispatched after its run was abandoned, or that was still running then.causeis why the run was abandoned.REACTION_FINISHED(no exported class; the run already ended). A command a reaction dispatched, or aforgetit called, after its run had finished, from a timer or a promise it left behind. Dispatch and forget while the handler runs.CHAIN_DEPTH_EXCEEDED(ChainDepthExceededError; terminal). A chain of reactions went deeper thanruntime.policies.maxChainDepth, by a command or by aforgeta policy or process called.depth,maxDepth.IDEMPOTENCY_KEY_CONFLICT(IdempotencyKeyConflictError; terminal). A dispatch’sidempotencyKeywas already used, withinruntime.commands.idempotencyKeyLifetime, for another command or for the same command with another payload ordelay. Nothing runs.idempotencyKey. See idempotent commands.IDEMPOTENT_ANSWER_ERASED(IdempotentAnswerErasedError; terminal). A dispatch’sidempotencyKeynames a command that ran, but whose answer was erased with the personal data of someone it named, forgotten or redacted since. Nothing runs, whatever the payload, until the key expires.idempotencyKey. See remembered answers.PROCESSING_RESTRICTED(ProcessingRestrictedError; terminal). Work would process data a restriction covers, on no basis that opens it: a command that touches a person restricted as a whole, the one its payload names withpersonor whose aggregate is the person, or whose aggregate’s events hold data a restriction covers, refused before its handler runs; one restricted while it ran, or whose events seal a field of a restricted category, refused as its events are appended; a dispatch whoseidempotencyKeywould replay an answer that names such a person; a policy, process step or scheduled command on such data, before its handler runs. Nothing is stored and nothing is recorded.personId. A reaction’s letter with this code is retried by the runtime onceunrestrictlifts the restriction;processRestricted, orrestrictedin a policy or process, names the basis that lets the work through.CREATION_ORDER(CreationOrderError; terminal). A command returned events that do not fit whether its aggregate exists: the first event is not one that exportsbegin, or an event that only exportsbegingoes on an aggregate that exists. Nothing is stored.NOT_FOUND(NotFoundError; terminal). An unknown command or query, or a requested row or registry entry that does not exist.INVALID_CONFIGURATION(ConfigurationError; terminal).bounda.config.tsor the registry is malformed: an unknown key, a port with no implementation chosen, a module missing an export. Thrown at boot, or when a handler reads a port a test left out. Also thrown at start by a database whose Bounda tables a version before 0.2.0 created.FORGET_LEDGER_UNAVAILABLE(ForgetLedgerUnavailableError; a forgetting’s answer). Thrown byforget,forgetAgain,bounda forgetand a policy’s or process’sforgetwhenruntime.personalData.forgetLedger.strictis set and the forget ledger did not take the forgetting’s intention: nothing was forgotten, so trying again is safe.causeis the ledger’s error, aForgetLedgerTimeoutErrorwhen it did not answer in time.FORGET_LEDGER_TIMEOUT(ForgetLedgerTimeoutError, withoperationandtimeoutMs). A call to the forget ledger did not settle withinruntime.personalData.forgetLedger.timeout: thecauseofFORGET_LEDGER_UNAVAILABLEandFORGET_LEDGER_UNRECONCILED, and what an app that is not strict logs. The call may still land after it.FORGET_LEDGER_UNRECONCILED(ForgetLedgerUnreconciledError; a start’s answer). Thrown bycreateApp, and so bybootand the CLI, whenruntime.personalData.forgetLedger.strictis set and the forget ledger could not be read through: the app does not start, since a person a restored backup brought back could be read.causeis the ledger’s error. Starting again tries again.RESTORE_UNRECONCILED(RestoreUnreconciledError; a read’s answer). Thrown, whenruntime.personalData.forgetLedger.strictis set, by a query, an export or a read of the dead letters or the subscribers’ failures that found the database restored from an earlier copy, or that ran before the forget ledger was reconciled with one: nothing it read is handed out.causeis the ledger’s error when it could not be read. Transient: the same read succeeds once the ledger is reconciled and the read models projected what it committed again.READ_MODEL_RESTORING(ReadModelRestoringError, withreadModel; a read’s answer). Thrown by a query or export of a read model whose database of its own was restored from another moment than the stream: it stands behind where it was, or is projected again from the start. Nothing was read from it. Transient: the same read succeeds once it caught up.STORAGE_SCHEMA_TOO_NEW(StorageSchemaTooNewError; a start’s answer). Thrown bycreateApp, and so bybootand the CLI, and bymigrateTablesandbounda migrate, when a newer version of Bounda has migrated the database’s Bounda tables past what this version knows:scope(storage,checkpointsorforget-ledger), itsversion, andsupported, the newest this version knows. The app does not start and nothing is written: Bounda never takes a schema back. Run that version or a later one, or restore a backup taken before it migrated.CLAIM_LOST(ClaimLostError; handled by the runtime). A reaction’s inbox claim expired and another instance took it over. The attempt writes nothing; the other instance’s run is the one that counts.SCHEDULED_CLAIM_LOST(ScheduledClaimLostError; handled by the runtime). The same for a scheduled command, a delayed policy run or a deadline, or the command was cancelled.IDEMPOTENCY_KEY_TAKEN(IdempotencyKeyTakenError; handled by the runtime). Of two dispatches racing for oneidempotencyKey, the one that lost: what it stored rolls back, and it answers what the key holds.DEAD_LETTER_SETTLED(DeadLetterSettledError; an operator’s answer). A dead letter was retried or discarded after another retry or discard had settled it.DEAD_LETTER_NOT_RETRIABLE(DeadLetterNotRetriableError; an operator’s answer). A dead letter cannot be retried in the app as it is now: its handler is gone or no longer handles the event, its process failed on another step first, or the person whose data its scheduled command holds was forgotten since. The letter staysfailed.REBUILD_SUPERSEDED(RebuildSupersededError; an operator’s answer). Another rebuild of the same read model took over; this one stopped without writing.readModel.SNAPSHOT_FAILED(SnapshotError; only in an app fromcreateTestApp). A snapshot did not stand for its stream: the state folded from it differs from the one folded from the first event, or the state cannot be serialized. Thrown by the command that loaded it or byrunUntilIdle(). Any other app logs it, drops the snapshot and folds the stream from the start.
The last three are answers to an operator, from app.deadLetters, bounda dead-letters and
bounda rebuild, not failures of a handler.
Over HTTP
Section titled “Over HTTP”The hosts map the codes a client can cause to a status:
| Code | createWorker (Cloudflare) |
failure() (React Router) |
|---|---|---|
VALIDATION_FAILED |
400, with issues |
400, with issues |
DOMAIN_ERROR |
409, with rejected |
409, with rejected |
PROCESSING_RESTRICTED |
409 | 409 |
TENANT_FORGOTTEN |
410 | 410 |
TENANT_FROZEN |
423 | 423 |
READ_MODEL_RESTORING |
503 | rethrown |
RESTORE_UNRECONCILED |
503 | rethrown |
IDEMPOTENCY_KEY_CONFLICT |
500, code INTERNAL, logged |
422 |
IDEMPOTENT_ANSWER_ERASED |
500, code INTERNAL, logged |
410 |
CONCURRENCY_CONFLICT |
409 | rethrown |
CHAIN_DEPTH_EXCEEDED |
409 | rethrown |
FOREIGN_REJECTION |
500, code INTERNAL, logged |
rethrown |
NOT_FOUND |
404 | rethrown |
PAYLOAD_TOO_LARGE |
413, a body over maxPayloadBytes |
— |
HANDLER_TIMEOUT |
504 | rethrown |
| anything else | 500, code INTERNAL, logged |
rethrown, for the route’s ErrorBoundary |
createWorker answers with { error: { code, message } }, and 400 with INVALID_JSON for a
body it cannot parse. failure() goes by the code too, so it answers the same whether the app runs
in the process or in a Durable Object, whose refusals arrive as plain errors. See
errors from the domain and
the Cloudflare adapter.