pub struct RenderError { /* private fields */ }Expand description
Main error type for rendering operations: a non-empty collection of
Diagnostics.
There is no failure taxonomy beyond the diagnostics themselves — the
machine-routable identity of a failure is each diagnostic’s namespaced
code (parse::*, validation::*, quill::*, typst::*, backend::*,
engine::*). Every consumer, and every language binding, handles all
rendering errors through this single shape; route on
diagnostics()[..].code, not on a type.
Implementations§
Source§impl RenderError
impl RenderError
Sourcepub fn new(diags: Vec<Diagnostic>) -> Self
pub fn new(diags: Vec<Diagnostic>) -> Self
Wrap diags as a failure. diags should be non-empty; the invariant is
enforced only by debug_assert!, so a release build can construct an
empty RenderError. That is deliberately non-fatal: the Display impl
carries an [] fallback branch rather than promising the invariant is
load-bearing. Every internal caller passes a non-empty vec.
Sourcepub fn from_diag(diag: Diagnostic) -> Self
pub fn from_diag(diag: Diagnostic) -> Self
Wrap a single diagnostic as a failure.
Sourcepub fn diagnostics(&self) -> &[Diagnostic]
pub fn diagnostics(&self) -> &[Diagnostic]
Returns all diagnostics for this error. Non-empty by construction (see
RenderError::new’s debug-asserted invariant).
Sourcepub fn into_diagnostics(self) -> Vec<Diagnostic>
pub fn into_diagnostics(self) -> Vec<Diagnostic>
Consume the error and return its diagnostics.
Sourcepub fn summary_message(diags: &[Diagnostic]) -> String
pub fn summary_message(diags: &[Diagnostic]) -> String
The count-based summary line shared by Display and every binding’s
exception message: the sole diagnostic’s message for one, an
"<N> error(s): <first message>" aggregate for more. The single source
of truth for this rule — bindings delegate here rather than re-deriving
it. An empty slice yields "render error" defensively (see
RenderError::new’s debug-only non-empty invariant).
Trait Implementations§
Source§impl Debug for RenderError
impl Debug for RenderError
Source§impl Display for RenderError
The primary message for a single diagnostic; an
"<N> error(s): <first message>" aggregate for more — the same rule the
WASM binding applies to thrown Error.message.
impl Display for RenderError
The primary message for a single diagnostic; an
"<N> error(s): <first message>" aggregate for more — the same rule the
WASM binding applies to thrown Error.message.
Source§impl Error for RenderError
impl Error for RenderError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()