pub enum LuaError {
SyntaxError {
message: String,
incomplete_input: bool,
},
RuntimeError(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<Error>),
}
Error type returned by rlua
methods.
Syntax error while parsing Lua source code.
Fields of SyntaxError
The error message as returned by Lua.
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.
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).
Lua garbage collector error, aka LUA_ERRGCMM
.
The Lua VM returns this error when there is an error running a __gc
metamethod.
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 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.
Too many arguments to Function::bind
A Rust value could not be converted to a Lua value.
Fields of ToLuaConversionError
Name of the Rust type that could not be converted.
Name of the Lua type that could not be created.
A message indicating why the conversion failed in more detail.
A Lua value could not be converted to the expected Rust type.
Fields of FromLuaConversionError
Name of the Lua type that could not be converted.
Name of the Rust type that could not be created.
A string containing more detailed error information.
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
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
Lua call stack backtrace.
Original error returned by the Rust code.
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.
Formats the value using the given formatter. Read more
Performs copy-assignment from source
. Read more
Returns a reference to the underlying cause of this failure, if it is an error that wraps other errors. Read more
Returns a reference to the Backtrace
carried by this failure, if it carries one. Read more
fn context<D>(self, context: D) -> Context<D> where D: Display + Send + Sync + 'static, | |
fn compat(self) -> Compat<Self> | |
Wraps this failure in a compatibility wrapper that implements std::error::Error
. Read more
Formats the value using the given formatter. Read more
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String
. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
impl<T> AsFail for T where T: Fail, | |
fn as_fail(&self) -> &(dyn Fail + 'static) | |
Converts a reference to Self
into a dynamic trait object of Fail
.
Returns a reference to the underlying cause of this failure, if it is an error that wraps other errors. Read more
Returns a reference to the Backtrace
carried by this failure, if it carries one. Read more
fn context<D>(self, context: D) -> Context<D> where D: Display + Send + Sync + 'static, | |
fn compat(self) -> Compat<Self> | |
Wraps this failure in a compatibility wrapper that implements std::error::Error
. Read more