Structured error produced by the framework.
:kind-:business(the domain said no; retrying gives the same answer) or:infrastructure(the system failed; retrying may succeed). Event handlers use it: a business error is a recorded rejection, an infrastructure error is retried.:entity- business entity (module) that produced the error:entity_id- the identity (Entity.identity/1) of the instance it happened to, ornilwhen there is none yet or it can't be told (anewcall that is missing its identity):operation- operation being run (:new,:update,:validateor adefopname):code- machine-matchable code, e.g.:validation_failed:message- human-readable message:details- data produced by the rule that failed:violations- list of%{field, code, message, details}when several rules failed:context- added by outer layers (running a command adds:command)
Summary
Functions
Build a business error: the domain decided no. Never retried.
True for business errors.
All violation codes of an error (or [code] when there are no violations).
True when the error, or any of its violations, has the given code.
Build an infrastructure error: the system failed. Retried by event handlers.
True for infrastructure errors.
Build an error from a keyword list or map.
Merge extra context into the error.
Per-field map of messages (form style): %{field => [message]}.
Errors without violations are reported under :base.
Build a :validation_failed error from a non-empty list of violations.
Build a violation map (one failed rule).
Convert any error reason into a DDD.Error, merging context.
Types
@type kind() :: :business | :infrastructure
Functions
Build a business error: the domain decided no. Never retried.
True for business errors.
All violation codes of an error (or [code] when there are no violations).
True when the error, or any of its violations, has the given code.
Build an infrastructure error: the system failed. Retried by event handlers.
True for infrastructure errors.
Build an error from a keyword list or map.
Merge extra context into the error.
Per-field map of messages (form style): %{field => [message]}.
Errors without violations are reported under :base.
Build a :validation_failed error from a non-empty list of violations.
Build a violation map (one failed rule).
Convert any error reason into a DDD.Error, merging context.
Errors pass through. Atoms and {code, message} tuples are wrapped as :business
errors (a plain reason is the domain's answer). An exception becomes an :infrastructure
error with code :exception. Anything else becomes :unknown (business) with the
inspected reason in details.