Enum mlua::Error [−][src]
#[non_exhaustive] pub enum Error {}Show variants
SyntaxError { message: StdString, incomplete_input: bool, }, RuntimeError(StdString), MemoryError(StdString), GarbageCollectorError(StdString), SafetyError(StdString), MemoryLimitNotAvailable, MainThreadNotAvailable, RecursiveMutCallback, CallbackDestructed, StackError, BindError, ToLuaConversionError { from: &'static str, to: &'static str, message: Option<StdString>, }, FromLuaConversionError { from: &'static str, to: &'static str, message: Option<StdString>, }, CoroutineInactive, UserDataTypeMismatch, UserDataDestructed, UserDataBorrowError, UserDataBorrowMutError, MismatchedRegistryKey, CallbackError { traceback: StdString, cause: Arc<Error>, }, PreviouslyResumedPanic, SerializeError(StdString), DeserializeError(StdString), ExternalError(Arc<dyn StdError + Send + Sync>),
Error type returned by mlua
methods.
Variants (Non-exhaustive)
Syntax error while parsing Lua source code.
Fields of SyntaxError
RuntimeError(StdString)
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(StdString)
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(StdString)
Lua garbage collector error, aka LUA_ERRGCMM
.
The Lua VM returns this error when there is an error running a __gc
metamethod.
SafetyError(StdString)
Potentially unsafe action in safe mode.
Setting memory limit is not available.
This error can only happen when Lua state was not created by us and does not have the custom allocator attached.
Main thread is not available.
This error can only happen in Lua5.1/LuaJIT module mode, when module loaded within a coroutine.
These Lua versions does not have LUA_RIDX_MAINTHREAD
registry key.
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.
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.
Not enough stack space to place arguments to Lua functions or return values from callbacks.
Due to the way mlua
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.
Too many arguments to Function::bind
A Rust value could not be converted to a Lua value.
Fields of ToLuaConversionError
A Lua value could not be converted to the expected Rust type.
Fields of FromLuaConversionError
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.
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.
An AnyUserData
borrow failed because it has been destructed.
This error can happen either due to to being destructed in a previous __gc, or due to being
destructed from exiting a Lua::scope
call.
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.
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.
A RegistryKey
produced from a different Lua state was used.
A Rust callback returned Err
, raising the contained Error
as a Lua error.
Fields of CallbackError
A Rust panic that was previosly resumed, returned again.
This error can occur only when a Rust panic resumed previously was recovered and returned again.
SerializeError(StdString)
serialize
only.Serialization error.
DeserializeError(StdString)
serialize
only.Deserialization error.
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
impl Error
[src]
Trait Implementations
impl Clone for Error
[src]
impl Debug for Error
[src]
impl Display for Error
[src]
impl Error for Error
[src]
fn source(&self) -> Option<&(dyn StdError + 'static)>
[src]
pub fn backtrace(&self) -> Option<&Backtrace>
[src]
pub fn description(&self) -> &str
1.0.0[src]
pub fn cause(&self) -> Option<&dyn Error>
1.0.0[src]
impl Error for Error
[src]
fn custom<T: Display>(msg: T) -> Self
[src]
pub fn invalid_type(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
[src]
pub fn invalid_value(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
[src]
pub fn invalid_length(len: usize, exp: &dyn Expected) -> Self
[src]
pub fn unknown_variant(variant: &str, expected: &'static [&'static str]) -> Self
[src]
pub fn unknown_field(field: &str, expected: &'static [&'static str]) -> Self
[src]
pub fn missing_field(field: &'static str) -> Self
[src]
pub fn duplicate_field(field: &'static str) -> Self
[src]
impl Error for Error
[src]
impl From<AddrParseError> for Error
[src]
fn from(err: AddrParseError) -> Self
[src]
impl From<Error> for Error
[src]
impl From<Utf8Error> for Error
[src]
impl<'lua> FromLua<'lua> for Error
[src]
impl<'lua> ToLua<'lua> for Error
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl !UnwindSafe for Error
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,