AshLua.Error protocol (ash_lua v0.1.0)

Copy Markdown View Source

Protocol for rendering Ash errors into the Lua-side error shape.

Each to_error/1 impl returns a map with these keys (all strings on the Lua side):

  • :message — the human-readable message to surface
  • :short_message — a terse variant suitable for tooltips/logs
  • :code — a stable, machine-readable identifier (e.g. "invalid_argument", "required", "not_found")
  • :fields — list of atom field names this error relates to (may be empty)
  • :vars — additional template/context variables interpolatable into message

Errors without an impl fall through to an opaque "unknown error" entry in the encoder.

Summary

Types

t()

All the types that implement this protocol.

Types

t()

@type t() :: term()

All the types that implement this protocol.

Functions

to_error(exception)

@spec to_error(term()) :: %{
  message: String.t(),
  short_message: String.t(),
  code: String.t(),
  fields: [atom()],
  vars: map()
}