Enum rlua::Error
[−]
[src]
pub enum Error { SyntaxError { message: String, incomplete_input: bool, }, RuntimeError(String), GarbageCollectorError(String), RecursiveCallbackError, ExpiredUserData, ToLuaConversionError { from: &'static str, to: &'static str, message: Option<String>, }, FromLuaConversionError { from: &'static str, to: &'static str, message: Option<String>, }, CoroutineInactive, UserDataTypeMismatch, UserDataBorrowError, UserDataBorrowMutError, CallbackError { traceback: String, cause: Arc<Error>, }, ExternalError(Arc<StdError + Send + Sync>), }
Error type returned by rlua
methods.
Variants
SyntaxError
Syntax error while parsing Lua source code.
Fields of SyntaxError
message: String | The error message as returned by Lua. |
incomplete_input: bool |
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).
GarbageCollectorError(String)
Lua garbage collector error, aka LUA_ERRGCMM
.
The Lua VM returns this error when there is an error running a __gc
metamethod.
RecursiveCallbackError
A callback has triggered Lua code that has called the same callback again.
This is an error because rlua
callbacks are FnMut and thus can only be mutably borrowed
once.
ExpiredUserData
Lua code has accessed a UserData
value that was already garbage collected
This can happen when a UserData
has a custom __gc
metamethod, this method resurrects
the UserData
, and then the UserData
is subsequently accessed.
ToLuaConversionError
A Rust value could not be converted to a Lua value.
Fields of ToLuaConversionError
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 of FromLuaConversionError
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.
CallbackError
A Rust callback returned Err
, raising the contained Error
as a Lua error.
Fields of CallbackError
traceback: String | Lua call stack backtrace. |
cause: Arc<Error> | Original error returned by the Rust code. |
ExternalError(Arc<StdError + 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.
Methods
impl Error
[src]
Trait Implementations
impl Debug for Error
[src]
impl Clone for Error
[src]
fn clone(&self) -> Error
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Display for Error
[src]
fn fmt(&self, fmt: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl StdError for Error
[src]
fn description(&self) -> &str
[src]
A short description of the error. Read more
fn cause(&self) -> Option<&StdError>
[src]
The lower-level cause of this error, if any. Read more