Promote saga error→ProjectionError helper to @octant/event-sourcing #46

Closed
opened 2026-07-04 12:11:39 +00:00 by momsse · 0 comments
Owner

Migré depuis viziertronic/octant#103 — ouvert le 2026-06-27 par @momsse.

Transverse refactor surfaced repeatedly in reviews (#100, #32 local review).

The describe*Error + to*ProjectionError pair is now duplicated three times, byte-identical except for the source-error union:

  • packages/domain/authorization/src/application/sagas/cascade-saga-error.ts
  • packages/application/transaction-matching/src/sagas/saga-error.ts
  • packages/domain/banking/src/application/sagas/banking-saga-error.ts

The ConcurrencyError formatting branch and the factory are identical; only the union of decide errors differs. A format change to one silently drifts from the others.

Proposed work

Add a generic toProjectionError(projectionName, prefix) to @octant/event-sourcing (next to wrapEventStoreError in projection.ts) that handles the ConcurrencyError branch and the message-or-JSON.stringify fallback over any { _tag; message } error, then adopt it in all three saga families and delete the local copies.

Scope note

Touches three already-merged packages, so kept out of the #32 PR. Pure refactor; behaviour-preserving.

> _Migré depuis [viziertronic/octant#103](https://github.com/viziertronic/octant/issues/103) — ouvert le 2026-06-27 par @momsse._ Transverse refactor surfaced repeatedly in reviews (#100, #32 local review). The `describe*Error` + `to*ProjectionError` pair is now duplicated **three times**, byte-identical except for the source-error union: - `packages/domain/authorization/src/application/sagas/cascade-saga-error.ts` - `packages/application/transaction-matching/src/sagas/saga-error.ts` - `packages/domain/banking/src/application/sagas/banking-saga-error.ts` The `ConcurrencyError` formatting branch and the factory are identical; only the union of decide errors differs. A format change to one silently drifts from the others. ## Proposed work Add a generic `toProjectionError(projectionName, prefix)` to `@octant/event-sourcing` (next to `wrapEventStoreError` in `projection.ts`) that handles the `ConcurrencyError` branch and the `message`-or-`JSON.stringify` fallback over any `{ _tag; message }` error, then adopt it in all three saga families and delete the local copies. ## Scope note Touches three already-merged packages, so kept out of the #32 PR. Pure refactor; behaviour-preserving.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
momsse/octant#46
No description provided.