Lantern.Errors (Lantern v0.6.0)

Copy Markdown View Source

Turns raw database and query errors into honest, human-readable copy for the UI. The cardinal rule: never leak a raw struct (a %DBConnection.ConnectionError{} or %Postgrex.Error{} dumped via inspect/1) into the interface.

humanize/1 is the single chokepoint every error-rendering path routes through — table loads, the SQL workspace, row edits, and connection setup.

For Postgres query errors it surfaces Postgres's own message and, when it can, appends a short plain-language hint (the server's own HINT: if present, else one derived from the SQLSTATE code).

Summary

Functions

The friendly connection-failure message. Exposed so callers that already know the failure is a connection problem (e.g. opening the socket) can use it directly without constructing an error term.

Converts an error term into display copy. Always returns a string; never an inspect/1 of a struct.

Functions

connection_error()

@spec connection_error() :: String.t()

The friendly connection-failure message. Exposed so callers that already know the failure is a connection problem (e.g. opening the socket) can use it directly without constructing an error term.

humanize(error)

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

Converts an error term into display copy. Always returns a string; never an inspect/1 of a struct.