AshGettext.Resource.Transformers.AttachErrorHandler (AshGettext v0.1.0)

Copy Markdown View Source

Point every write action's error_handler at AshGettext.ErrorTranslation.ErrorHandler.

Doing this at compile time is what makes translation a property of the resource rather than a thing each action has to remember. Adding an action to a resource that uses AshGettext.Resource cannot forget to translate.

Two deliberate limits:

  • Write actions only. Ash 3.29 exposes error_handler on create, update and destroy — the changeset-based actions. Read and generic actions have no equivalent hook, so their errors are not translated here.
  • An action that already declares an error_handler is left alone. The app asked for that handler explicitly; silently replacing it would be a worse surprise than an untranslated message.

Summary

Functions

after_compile?()

Callback implementation for Spark.Dsl.Transformer.after_compile?/0.

before?(_)

Callback implementation for Spark.Dsl.Transformer.before?/1.