#[non_exhaustive]pub struct LuaFailure {
pub kind: LuaErrorKind,
pub message: String,
pub traceback: Option<String>,
}Expand description
A Lua error, as it crosses from the VM thread to Rust.
Built on the VM thread from the raised value (or from the
mlua::Error when the error came from Rust or from mlua), so it is
Send + Sync. The raw value itself stays on the Lua side: a host
that needs it (an error object with a metatable, say) catches it
with pcall in Lua.
Display prints message.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.kind: LuaErrorKindThe kind of error.
message: StringThe error as Lua prints it: tostring(err) on the VM thread
(so a __tostring metamethod is honoured). For an error that
came from Rust, its Display (for a CallbackError, the
innermost cause; for a RuntimeError, the message without the
traceback).
traceback: Option<String>The Lua stack traceback at the point of the error, when one was taken (errors raised in Lua and errors from Rust functions called from Lua have one; an error before any Lua ran, such as a syntax error, does not).
Implementations§
Source§impl LuaFailure
impl LuaFailure
Sourcepub fn new(kind: LuaErrorKind, message: impl Into<String>) -> Self
pub fn new(kind: LuaErrorKind, message: impl Into<String>) -> Self
A failure of kind with message and no traceback (or value).
For an exec closure that reports its own error:
Err(IsleError::Lua(LuaFailure::new(LuaErrorKind::Runtime, "bad input"))).
Sourcepub fn from_mlua(e: &Error) -> Self
pub fn from_mlua(e: &Error) -> Self
Build a failure from an mlua::Error: the kind from the
variant, the message from its Display (see
message), the traceback from a
CallbackError or from the traceback mlua appends to a
RuntimeError.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LuaFailure
impl RefUnwindSafe for LuaFailure
impl Send for LuaFailure
impl Sync for LuaFailure
impl Unpin for LuaFailure
impl UnsafeUnpin for LuaFailure
impl UnwindSafe for LuaFailure
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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