PhoenixKitSync.Errors (PhoenixKitSync v0.2.5)

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).

Translations are in this module's own catalogue (PhoenixKitSync.Gettext, priv/gettext). Every clause calls gettext/1 with a literal string so mix gettext.extract sees it. 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.

The text for a transfer's stored error_message.

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
  | :empty_schema
  | :fetch_failed
  | :filter_needs_single_key
  | :import_failed
  | :incoming_denied
  | :invalid_code
  | :invalid_cursor
  | :invalid_registration
  | :invalid_column_name
  | :invalid_column_type
  | :invalid_filter
  | :invalid_identifier
  | :invalid_json
  | :invalid_password
  | :invalid_response
  | :invalid_sender_url
  | :invalid_status
  | :invalid_table_name
  | :invalid_token
  | :ip_not_allowed
  | :join_timeout
  | :missing_fields
  | :table_excluded
  | :table_not_allowed
  | :missing_code
  | :missing_connection_info
  | :module_disabled
  | :no_primary_key
  | :not_found
  | :nxdomain
  | :offline
  | :outside_allowed_hours
  | :paging_stalled
  | :password_required
  | :pull_failed
  | :record_limit_reached
  | :response_too_large
  | :schema_without_primary_key
  | :sent_truncated
  | :source_without_primary_key
  | :status_change_not_allowed
  | :too_many_pending
  | :sender_ignores_filters
  | :table_missing_locally
  | :table_not_found
  | :timeout
  | :truncated
  | :unauthorized
  | :unavailable
  | :unexpected_response
  | :unsupported_key_type
  | :unsupported_column_type

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.

transfer_error(error_message)

@spec transfer_error(String.t() | nil) :: String.t() | nil

The text for a transfer's stored error_message.

A reason this module classified is stored as its error atom's name and translated here, so History shows it in the reader's language; any other text (an older row, a remote site's own message) is shown as stored.