Files
accounted/lib/pending-operations/errors.ts
T
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

32 lines
1.3 KiB
TypeScript

/**
* Typed errors for the pending-operations commit path.
*
* PartialCommitError is thrown by multi-step executors when an irreversible
* side-effect (posted voucher, persisted credit note) already exists and a
* LATER step fails. The dispatcher (commitPendingOperationInner) detects it
* and lands the op in the terminal status 'failed_partial' instead of
* 'rejected', persisting the posted ids in result_data.posted_ids so an
* operator can locate the orphaned voucher/entity (issue #842).
*
* Do NOT throw this before the first irreversible step: a clean failure with
* nothing posted must keep today's 'rejected' semantics.
*/
export class PartialCommitError extends Error {
readonly name = 'PartialCommitError'
/**
* Ids of the entities that were irreversibly created before the failure,
* keyed by a stable snake_case label (e.g. reversal_journal_entry_id,
* payment_journal_entry_id, credit_note_id). Persisted verbatim into
* pending_operations.result_data.posted_ids.
*/
readonly postedIds: Record<string, string>
/** The underlying failure that interrupted the executor. */
readonly cause: unknown
constructor(message: string, postedIds: Record<string, string>, cause?: unknown) {
super(message)
this.postedIds = postedIds
this.cause = cause
}
}