The one error this SDK answers anything Flezha refuses with: a stable code
spelled family.snake, a class, a plain message, the details the
message names, and a hint naming the next command when there is one.
A refusal the controller sent carries its own rendering, read by
from_wire/1. A refusal this SDK makes itself, a declaration or a runtime
misuse, is built by new/2 from the catalogue of the contract set
(crates/flz_transport/errors.json), the one the controller and the Rust core render
from, so a code reads the same in every language.
This module is also the Elixir renderer the controller's Flezha.Error
shares: render/2, object/1 and render_template/2 take any map carrying
the five fields.
Summary
Functions
The catalogue as it was compiled in.
details as the compact, key-sorted JSON object the wire carries.
The exit code a class answers.
The error a JSON error document carries ({"error": {...}}), as the core and
the controller render it; nil when document is not one.
The error a decoded error object (code, class, message, details,
hint) carries; nil when it names no code.
The error a controller reply carried as a wire Error message; nil for a
reply that carries none.
The error code names, its templates filled from details. A code the
catalogue does not know is internal.uncatalogued, naming it.
The {code, class, message, details, hint} object, as JSON with a fixed key order.
Details a caller can read without knowing Elixir: string keys, and values that are text, numbers, booleans, lists or string-keyed objects. Any other term is its inspect.
:text is error: <message> (<code>) and a hint: line; :json the one-line document.
template with every {key} replaced by details[key] as text: a string as
written, a list of strings joined by ,, anything else as compact JSON. A
key the details do not carry is left as written.
Types
Functions
@spec catalogue() :: map()
The catalogue as it was compiled in.
details as the compact, key-sorted JSON object the wire carries.
@spec exit_code(%{class: class()}) :: pos_integer()
The exit code a class answers.
The error a JSON error document carries ({"error": {...}}), as the core and
the controller render it; nil when document is not one.
The error a decoded error object (code, class, message, details,
hint) carries; nil when it names no code.
The error a controller reply carried as a wire Error message; nil for a
reply that carries none.
The error code names, its templates filled from details. A code the
catalogue does not know is internal.uncatalogued, naming it.
The {code, class, message, details, hint} object, as JSON with a fixed key order.
Details a caller can read without knowing Elixir: string keys, and values that are text, numbers, booleans, lists or string-keyed objects. Any other term is its inspect.
:text is error: <message> (<code>) and a hint: line; :json the one-line document.
template with every {key} replaced by details[key] as text: a string as
written, a list of strings joined by ,, anything else as compact JSON. A
key the details do not carry is left as written.