Logos. EvalError exception
(Logos v0.2.0)
Copy Markdown
The Elixir exception carrying a primitive-level evaluation failure --
division by zero, an unbound symbol, a wrong-arity call, and every
other case Logos.Eval/Logos.Primitives used to signal via a plain
{:error, reason} return before this module existed. reason is
exactly what that tuple's second element always was -- this is a
mechanical change in how a failure propagates (raise instead of
return), not in what failures look like.
Modeled directly on Logos.MacroError (Logos.Macroexpand), which
already used this exact pattern for macro-expansion failures before
this module did. Logos.Eval's try special form rescues this
specifically (alongside Logos.Thrown) so Logos-level (try ... (catch ...)) can catch a primitive-level failure too, not just an
explicit (throw ...) -- see eval_try/3's own comment for the tag-
matching rules. Uncaught, it propagates as an ordinary Elixir
exception; Logos.eval_string/3's outermost boundary rescues it back
into {:error, reason}, so the public top-level API's contract is
completely unchanged by this.