Sigra.Error (Sigra v0.2.2)

Copy Markdown View Source

Error types and safe message mapping for Sigra authentication.

Sigra uses structured error types for precise internal error handling, combined with a safe_message/1 function that maps internal errors to enumeration-safe user-facing strings.

Error Types

Enumeration Prevention

The safe_message/1 function ensures that user-facing messages never leak information about which part of authentication failed. For example, :invalid_credentials always returns "Invalid email or password." -- never "wrong password" or "user not found".

Summary

Functions

Maps an internal error atom to an enumeration-safe user-facing message.

Functions

safe_message(arg1)

(since 0.1.0)
@spec safe_message(atom()) :: String.t()

Maps an internal error atom to an enumeration-safe user-facing message.

These messages are intentionally generic to prevent user enumeration attacks. Internal code uses precise error atoms; the safe message is for display to end users.

Examples

iex> Sigra.Error.safe_message(:invalid_credentials)
"Invalid email or password."

iex> Sigra.Error.safe_message(:token_expired)
"This link has expired. Please request a new one."