#[non_exhaustive]pub enum IsleError {
Shutdown,
Cancelled,
Lua(LuaFailure),
Init(LuaFailure),
NotFound(String),
ThreadPanic(Option<String>),
RecvFailed,
}Expand description
Errors returned by Isle operations.
Match on the variant; the Lua error of a request or root is
IsleError::Lua:
use mlua_isle::{Isle, IsleError, LuaErrorKind};
let isle = Isle::spawn(|_| Ok(())).unwrap();
match isle.eval::<()>("error('boom')") {
Err(IsleError::Lua(f)) => {
assert_eq!(f.kind, LuaErrorKind::Runtime);
assert!(f.message.ends_with("boom"));
}
other => panic!("unexpected: {other:?}"),
}
isle.shutdown().unwrap();Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Shutdown
The Lua VM thread has already shut down.
Cancelled
The operation was cancelled via CancelToken.
Lua(LuaFailure)
A request or root raised a Lua error.
Init(LuaFailure)
The init closure failed (or, for the kinds noted on
LuaErrorKind::External, the VM thread could not be set up).
NotFound(String)
call / coroutine_call named a global that is not a function.
Carries the name.
ThreadPanic(Option<String>)
The Lua thread panicked. Carries the panic message when the
payload is a &str or a String.
RecvFailed
Failed to receive response from the Lua thread.
The response channel was dropped before a result was sent. This typically means the Lua thread panicked or was shut down while a request was in flight.
Trait Implementations§
Source§impl Error for IsleError
impl Error for IsleError
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()
Source§impl From<Error> for IsleError
impl From<Error> for IsleError
Source§fn from(e: Error) -> Self
fn from(e: Error) -> Self
IsleError::Cancelled when e wraps Cancelled (found by
downcast, never by message), else IsleError::Lua.
Source§impl From<IsleError> for Error
impl From<IsleError> for Error
Source§fn from(e: IsleError) -> Self
fn from(e: IsleError) -> Self
Lets ? pass an IsleError out of a closure or host function that
returns mlua::Result (an init closure, a create_function /
create_async_function body).
IsleError::Cancelled becomes mlua::Error::external(Cancelled),
the same value the cancel hook raises, so a cancel stays a cancel
across the boundary: task.is_cancelled(err) is true for it in
Lua, and IsleError::from turns it back into
IsleError::Cancelled. Every other variant becomes
mlua::Error::external(e); brought back to Rust it is
IsleError::Lua(f) with f.message = e.to_string(), and
f.kind = LuaErrorKind::Callback when it came out of a host
function called from Lua (LuaErrorKind::External when it
did not cross a Lua call, e.g. from an init closure, which gives
IsleError::Init).
Auto Trait Implementations§
impl Freeze for IsleError
impl RefUnwindSafe for IsleError
impl Send for IsleError
impl Sync for IsleError
impl Unpin for IsleError
impl UnsafeUnpin for IsleError
impl UnwindSafe for IsleError
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<E> ExternalError for E
impl<E> ExternalError for E
fn into_lua_err(self) -> Error
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