AshGettext.ErrorTranslation.ErrorHandler (AshGettext v0.1.0)

Copy Markdown View Source

The error_handler that AshGettext.Resource installs on write actions.

Ash calls this with the changeset and each error it collects, and takes the return value as the error to keep. The error is translated into the language of the action's actor, else Gettext's current language.

It sits below every transport by design. An error from a custom validation, a builtin constraint, a value that does not cast, a missing required value or a failed policy all arrive here the same way. Errors the data layer returns after the change ran (a stale record) do not pass through it.

If the domain does not configure gettext, the error passes through untouched.

Summary

Functions

Translate error into the action's language.

Functions

translate_error(changeset, error)

@spec translate_error(Ash.Changeset.t(), term()) :: term()

Translate error into the action's language.