Atom → translated-string dispatcher for Staff context errors.
Context functions return {:error, atom} (or {:error, %Ecto.Changeset{}}
for changeset errors); LiveViews call Errors.message/1 at the
presentation boundary to translate the atom into a flash-ready
user-facing string.
Keeping the dispatcher here means:
- Translation files only need to know about the literal strings in
this module — the gettext extractor sees the literals at the
gettext(...)call site of each branch. - Context functions stay storage-agnostic (no
gettextcalls inlib/phoenix_kit_staff/staff.ex); LiveViews are the one place that turns intent into copy. - Future changes to wording happen in one place; new error conditions get a new atom + a new branch here.
Summary
Types
Atoms that the Staff context returns inside {:error, atom} tuples.
Adding a new atom requires adding a message/1 branch below — the
not_found fallback then never fires for known shapes.
Functions
Translates a Staff error atom into a user-facing message.
Types
@type error_atom() ::
:blank_email
| :placeholder_already_claimed
| :email_already_taken
| :not_found
Atoms that the Staff context returns inside {:error, atom} tuples.
Adding a new atom requires adding a message/1 branch below — the
not_found fallback then never fires for known shapes.
Functions
@spec message(error_atom() | atom()) :: String.t()
Translates a Staff error atom into a user-facing message.
Defaults to a generic fallback for unknown atoms so that callers always get a renderable string (no raised pattern-match) — but a fallback that fires in production is a sign that a context fn returned an atom this module doesn't know about, and should be added here.