Skip to main content

ErrorInfo

Struct ErrorInfo 

Source
pub struct ErrorInfo {
    pub kind: &'static str,
    pub message: String,
    pub source: Option<String>,
    pub line: Option<u32>,
    pub module: Option<String>,
    pub traceback: Option<String>,
    pub cause: Vec<String>,
}
Expand description

A classified view of an Error: what broke, where, and why, as separate fields instead of one interpolated string.

Built on the error path only — the happy path never constructs one — by parsing what mlua already captured at raise time (position-prefixed messages and tracebacks), so classification adds no capture cost of its own. Production diagnostics use the concise fields (kind, source, line, module, message); the bounded traceback and cause chain exist for development mode and for error handlers that ask for them.

Fields§

§kind: &'static str

The classified failure: "lua" (a script error), "nitr" (a nitr.* builtin or Nitr’s own boundary), "module" (a registered extension module), "timeout", "memory", or "panic". The set is closed, so branching on it is stable in a way matching on message text never is — but it is classification, not provenance: "nitr" and "timeout" are recognized by message shape, so a script that raises "nitr.db: ..." or the budget message verbatim lands in those kinds too. It is fit for logging and error pages; no security decision may rest on it.

§message: String

The message with any position prefix and traceback stripped.

§source: Option<String>

The chunk that raised the error (the script path when the chunk was loaded from a file), when the message carried a position.

§line: Option<u32>

The line within source.

§module: Option<String>

The failing module ("nitr.db", or an extension’s mount name), when the error crossed the Rust/Lua boundary with attribution.

§traceback: Option<String>

The Lua call stack at the raise site, innermost first, bounded to [MAX_TRACEBACK_LINES] frames.

§cause: Vec<String>

The underlying Rust error chain, outermost first, bounded to [MAX_CAUSE_DEPTH] entries.

Implementations§

Source§

impl ErrorInfo

Source

pub fn from_error(err: &Error) -> Self

Classifies an error into its structured form.

Source

pub fn from_message(text: &str) -> Self

Classifies an error that arrives as bare text: what a Lua pcall catches from an error() or a runtime failure (app.lua:21: attempt to call a nil value ..., possibly with an appended traceback). Rust-side errors keep their full chain and should go through from_error instead.

Source

pub fn concise(&self) -> String

The concise single-line form used by production diagnostics: kind: message (source:line).

Source

pub fn concise_colored(&self) -> String

concise with ANSI color: the kind bold red, the message bold, the location cyan. Callers gate on the destination being a terminal — this string must never reach an HTTP body or a log file.

Trait Implementations§

Source§

impl Clone for ErrorInfo

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ErrorInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more