Central mapping from error atoms (returned by PhoenixKitOG.Templates,
PhoenixKitOG.Assignments, and the render pipeline) to translated,
user-facing strings.
Keeping UI copy in one place means every "not found" / "render failed"
flash reads the same wording, and translations live in core's gettext
backend rather than being scattered across LiveViews. Callers pattern-
match on atoms (or tagged tuples for atoms with parameters);
message/1 wraps each mapping in gettext/1 at the UI boundary.
Supported reason shapes
- plain atoms —
:not_found,:rasterizer_missing,:template_missing,:group_missing - tagged tuples —
{:render_failed, reason} Ecto.Changeset.t()— passed through unchanged so callers can keep the changeset for<.input>rendering- strings — passed through unchanged (legacy / interpolated messages)
- anything else — rendered as
"Unexpected error: <inspect>"so nothing silently surfaces a raw struct or tuple
Example
iex> PhoenixKitOG.Errors.message(:rasterizer_missing)
"Preview render needs the resvg NIF — check that the dep resolved on this build."
Summary
Types
Atoms returned by the public PhoenixKitOG API.
Functions
Translates an error reason into a user-facing string via gettext.
Types
@type error_atom() ::
:not_found
| :rasterizer_missing
| :template_missing
| :group_missing
| :render_failed
Atoms returned by the public PhoenixKitOG API.
Functions
@spec message(term()) :: String.t() | Ecto.Changeset.t()
Translates an error reason into a user-facing string via gettext.
Use this at the UI boundary — typically inside put_flash(:error, ...)
in a LiveView's handle_event/3 clause. Context functions return
raw atoms; the LV decides whether to surface the specific reason
(via this helper) or a generic flash for unhandled shapes.