PhoenixKitSync.Errors (PhoenixKitSync v0.1.4)

Copy Markdown View Source

Single translation point for every error atom the sync module emits.

Call sites return plain {:error, :atom} tuples — never free-text error strings — and the UI / API layer translates via message/1 at the boundary. This keeps error semantics testable (you assert on the atom, not on a string that might get reworded) and makes translations consistent (every place that surfaces :connection_expired renders the exact same gettext string).

Translation files live in core phoenix_kit; this module only calls gettext/1 with literal strings so mix gettext.extract in core picks them up correctly. Do NOT refactor this into a lookup map — the extractor only sees literal arguments to gettext/1 at the call site.

Unknown atoms fall through to inspect/1 so the catch-all returns a useful-if-ugly string rather than crashing.

Summary

Functions

Returns a human-readable message for an error atom, changeset, or other value. Safe for any input — falls through to inspect/1 for unknown terms.

Types

error_atom()

@type error_atom() ::
  :already_exists
  | :already_used
  | :cannot_start
  | :connection_exists
  | :connection_expired
  | :connection_not_active
  | :connection_timeout
  | :disconnected
  | :download_limit_reached
  | :econnrefused
  | :fetch_failed
  | :incoming_denied
  | :invalid_code
  | :invalid_identifier
  | :invalid_json
  | :invalid_password
  | :invalid_response
  | :invalid_status
  | :invalid_table_name
  | :invalid_token
  | :ip_not_allowed
  | :join_timeout
  | :missing_fields
  | :table_not_allowed
  | :missing_code
  | :missing_connection_info
  | :module_disabled
  | :not_found
  | :nxdomain
  | :offline
  | :outside_allowed_hours
  | :password_required
  | :record_limit_reached
  | :table_not_found
  | :timeout
  | :unauthorized
  | :unavailable
  | :unexpected_response

Functions

message(changeset)

@spec message(term()) :: String.t()

Returns a human-readable message for an error atom, changeset, or other value. Safe for any input — falls through to inspect/1 for unknown terms.