Central mapping from error atoms (returned by the Entities module's public API) to translated human-readable strings.
Keeping the API layer locale-agnostic means callers can pattern-match
on atoms and decide their own presentation. Anything user-facing
(flash messages, error banners) goes through message/1 which wraps
each mapping in gettext/1 using the PhoenixKitWeb.Gettext backend.
Supported reason shapes
- plain atoms —
:cannot_remove_primary,:not_multilang,:entity_not_found, etc. - tagged tuples —
{:invalid_field_type, type},{:requires_options, type},{:missing_required_keys, [keys]},{:user_entity_limit_reached, max}. The dynamic part is interpolated viagettextbindings so the wording lives in core.pofiles. - strings — passed through unchanged (legacy / pre-existing messages already translated at the call site)
- anything else — rendered as
"Unexpected error: <inspect>"via gettext so nothing silently surfaces a raw struct
Example
iex> PhoenixKitEntities.Errors.message(:cannot_remove_primary)
"Cannot remove the primary language."
iex> PhoenixKitEntities.Errors.message({:invalid_field_type, "blob"})
"Invalid field type: blob"
Summary
Types
Plain atoms returned by the Entities public API.
Tagged tuples carrying interpolation context.
Functions
Translates an error reason (atom, tagged tuple, or binary) into a user-facing string via gettext.
Types
@type error_atom() ::
:cannot_remove_primary
| :not_multilang
| :entity_not_found
| :not_found
| :invalid_format
| :unexpected
| :already_trashed
| :not_trashed
| :referenced_by_external
Plain atoms returned by the Entities public API.
@type tagged_error() :: {:invalid_field_type, String.t()} | {:requires_options, String.t()} | {:missing_required_keys, [String.t()]} | {:user_entity_limit_reached, non_neg_integer()}
Tagged tuples carrying interpolation context.