Skip to main content

IsleError

Enum IsleError 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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 Debug for IsleError

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for IsleError

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Error for IsleError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for IsleError

Source§

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

Source§

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§

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<E> ExternalError for E
where E: Into<Box<dyn Error>>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

Source§

impl<T> MaybeSync for T

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.