Skip to main content

Module error

Module error 

Source
Expand description

ISO Prolog error terms.

Built-ins and the solver construct PrologError values when something goes wrong. Each variant maps 1:1 to an ISO 13211-1 §7.12 formal error term; to_term renders the value as error(Formal, Context) so user-level catch/3 recovery clauses can pattern-match against the structured term.

Construction is cheap — no allocation on the success path. The optional context string lives in the second argument of error/2 and is the human-readable message format-style; existing tests grep for substrings in this field, so it’s where helpful detail goes.

Ported from patch-prolog’s error.rs; the only change is sourcing Term / StringInterner from plg_shared instead of the old in-crate term module.

Structs§

ThrownError
A thrown error as it flows through the solver. The term is what catch/3 pattern-matches against; the uncatchable flag is set for safety-ceiling errors (step limit) so user catch/3 clauses cannot trap them.

Enums§

PrologError
ISO formal-error vocabulary.

Functions§

format_term
Format an arbitrary term as a Prolog-syntax string. Used by the CLI for rendering uncaught error terms. Lives here (not in a general pretty-printer module) because the only consumer is the error path.