mapPersistenceError
mapPersistenceError(
error,operation):unknown
Defined in: packages/ddd-mikro-orm/src/errors/transient-error.ts:101
Translates persistence-specific transient failures into the neutral application retry signal. Non-transient failures are returned unchanged.
This is the canonical otherwise translator for @MapPersistenceErrors and
@PersistedWrite of @cqrs-ddd/core. Because non-transient errors keep their identity,
domain errors a repository throws on purpose (ConcurrencyConflictError,
EntityNotFoundException) pass through without a re-throw guard.
Parameters
Section titled “Parameters”unknown
The failure raised by the persistence operation.
operation
Section titled “operation”string
What was being done, for the message, such as
`deleting User ${user.id}`.
Returns
Section titled “Returns”unknown
A TransientOperationError whose cause is error, or
error itself when it is not transient.
Example
Section titled “Example”@MapPersistenceErrors<[User], User>({ entity: ([user]) => user, otherwise: (error, user) => mapPersistenceError(error, `deleting User ${user.id}`),})async save(user: User): Promise<null> { ... }
// Outside the lifecycle decorators:try { return await em.findOne(Auth, { refreshTokenHash: hash }, { refresh: true });} catch (error) { throw mapPersistenceError(error, 'auth session lookup');}