Enum Error

Source
pub enum Error {
Show 17 variants SyntaxError { message: String, incomplete_input: bool, }, RuntimeError(String), MemoryError(String), GarbageCollectorError(String), RecursiveMutCallback, CallbackDestructed, StackError, BindError, ToLuaConversionError { from: &'static str, to: &'static str, message: Option<String>, }, FromLuaConversionError { from: &'static str, to: &'static str, message: Option<String>, }, CoroutineInactive, UserDataTypeMismatch, UserDataBorrowError, UserDataBorrowMutError, MismatchedRegistryKey, CallbackError { traceback: String, cause: Arc<Error>, }, ExternalError(Arc<dyn Error + Send + Sync>),
}
Expand description

Error type returned by rlua methods.

Variants§

§

SyntaxError

Syntax error while parsing Lua source code.

Fields

§message: String

The error message as returned by Lua.

§incomplete_input: bool

true if the error can likely be fixed by appending more input to the source code.

This is useful for implementing REPLs as they can query the user for more input if this is set.

§

RuntimeError(String)

Lua runtime error, aka LUA_ERRRUN.

The Lua VM returns this error when a builtin operation is performed on incompatible types. Among other things, this includes invoking operators on wrong types (such as calling or indexing a nil value).

§

MemoryError(String)

Lua memory error, aka LUA_ERRMEM

The Lua VM returns this error when the allocator does not return the requested memory, aka it is an out-of-memory error.

§

GarbageCollectorError(String)

Lua garbage collector error, aka LUA_ERRGCMM.

The Lua VM returns this error when there is an error running a __gc metamethod.

§

RecursiveMutCallback

A mutable callback has triggered Lua code that has called the same mutable callback again.

This is an error because a mutable callback can only be borrowed mutably once.

§

CallbackDestructed

Either a callback or a userdata method has been called, but the callback or userdata has been destructed.

This can happen either due to to being destructed in a previous __gc, or due to being destructed from exiting a Lua::scope call.

§

StackError

Not enough stack space to place arguments to Lua functions or return values from callbacks.

Due to the way rlua works, it should not be directly possible to run out of stack space during normal use. The only way that this error can be triggered is if a Function is called with a huge number of arguments, or a rust callback returns a huge number of return values.

§

BindError

Too many arguments to Function::bind

§

ToLuaConversionError

A Rust value could not be converted to a Lua value.

Fields

§from: &'static str

Name of the Rust type that could not be converted.

§to: &'static str

Name of the Lua type that could not be created.

§message: Option<String>

A message indicating why the conversion failed in more detail.

§

FromLuaConversionError

A Lua value could not be converted to the expected Rust type.

Fields

§from: &'static str

Name of the Lua type that could not be converted.

§to: &'static str

Name of the Rust type that could not be created.

§message: Option<String>

A string containing more detailed error information.

§

CoroutineInactive

Thread::resume was called on an inactive coroutine.

A coroutine is inactive if its main function has returned or if an error has occured inside the coroutine.

Thread::status can be used to check if the coroutine can be resumed without causing this error.

§

UserDataTypeMismatch

An AnyUserData is not the expected type in a borrow.

This error can only happen when manually using AnyUserData, or when implementing metamethods for binary operators. Refer to the documentation of UserDataMethods for details.

§

UserDataBorrowError

An AnyUserData immutable borrow failed because it is already borrowed mutably.

This error can occur when a method on a UserData type calls back into Lua, which then tries to call a method on the same UserData type. Consider restructuring your API to prevent these errors.

§

UserDataBorrowMutError

An AnyUserData mutable borrow failed because it is already borrowed.

This error can occur when a method on a UserData type calls back into Lua, which then tries to call a method on the same UserData type. Consider restructuring your API to prevent these errors.

§

MismatchedRegistryKey

A RegistryKey produced from a different Lua state was used.

§

CallbackError

A Rust callback returned Err, raising the contained Error as a Lua error.

Fields

§traceback: String

Lua call stack backtrace.

§cause: Arc<Error>

Original error returned by the Rust code.

§

ExternalError(Arc<dyn Error + Send + Sync>)

A custom error.

This can be used for returning user-defined errors from callbacks.

Returning Err(ExternalError(...)) from a Rust callback will raise the error as a Lua error. The Rust code that originally invoked the Lua code then receives a CallbackError, from which the original error (and a stack traceback) can be recovered.

Implementations§

Source§

impl Error

Source

pub fn external<T>(err: T) -> Error
where T: Into<Box<dyn Error + Send + Sync>>,

Trait Implementations§

Source§

impl Clone for Error

Source§

fn clone(&self) -> Error

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Error for Error

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<'lua> FromLua<'lua> for Error

Source§

fn from_lua(value: Value<'lua>, lua: Context<'lua>) -> Result<Error, Error>

Performs the conversion.
Source§

impl<'lua> ToLua<'lua> for Error

Source§

fn to_lua(self, _: Context<'lua>) -> Result<Value<'lua>, Error>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for Error

§

impl !RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl !UnwindSafe for Error

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> AsFail for T
where T: Fail,

Source§

fn as_fail(&self) -> &(dyn Fail + 'static)

Converts a reference to Self into a dynamic trait object of Fail.
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<E> ExternalError for E
where E: Into<Box<dyn Error + Send + Sync>>,

Source§

impl<E> Fail for E
where E: Error + Send + Sync + 'static,

Source§

fn name(&self) -> Option<&str>

Returns the “name” of the error. Read more
Source§

fn cause(&self) -> Option<&(dyn Fail + 'static)>

Returns a reference to the underlying cause of this failure, if it is an error that wraps other errors. Read more
Source§

fn backtrace(&self) -> Option<&Backtrace>

Returns a reference to the Backtrace carried by this failure, if it carries one. Read more
Source§

fn context<D>(self, context: D) -> Context<D>
where D: Display + Send + Sync + 'static, Self: Sized,

Provides context for this failure. Read more
Source§

fn compat(self) -> Compat<Self>
where Self: Sized,

Wraps this failure in a compatibility wrapper that implements std::error::Error. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<'lua, T> FromLuaMulti<'lua> for T
where T: FromLua<'lua>,

Source§

fn from_lua_multi( values: MultiValue<'lua>, lua: Context<'lua>, ) -> Result<T, Error>

Performs the conversion. 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<'lua, T> ToLuaMulti<'lua> for T
where T: ToLua<'lua>,

Source§

fn to_lua_multi(self, lua: Context<'lua>) -> Result<MultiValue<'lua>, Error>

Performs the conversion.
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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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> Erased for T