PhoenixKitDocumentCreator.Errors (PhoenixKitDocumentCreator v0.2.8)

Copy Markdown View Source

Single translation point for every error atom the Document Creator module emits.

Call sites return plain {:error, :atom} tuples — never free-text strings — and the UI / API layer translates via message/1 at the boundary. This keeps error semantics testable (assert on the atom, not on a string that might get reworded) and makes translations consistent (every place that surfaces :templates_folder_not_found 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() ::
  :copy_failed
  | :create_document_failed
  | :create_folder_failed
  | :deleted_folder_not_found
  | :documents_folder_not_found
  | :file_trashed
  | :folder_not_found
  | :folder_search_failed
  | :get_file_parents_failed
  | :invalid_action
  | :invalid_file_id
  | :invalid_google_doc_id
  | :invalid_parent_folder_id
  | :list_files_failed
  | :live_folder_not_found
  | :max_depth_exceeded
  | :missing_google_doc_id
  | :missing_name
  | :move_failed
  | :no_doc_id
  | :no_thumbnail
  | :not_found
  | :pdf_export_failed
  | :sync_failed
  | :templates_folder_not_found
  | :thumbnail_fetch_failed
  | :thumbnail_link_failed

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.