#[non_exhaustive]pub enum Error {
Show 16 variants
SyntaxError {
message: String,
incomplete_input: bool,
},
RuntimeError(String),
MemoryError(String),
FromLuaConversionError {
from: &'static str,
to: String,
message: Option<String>,
},
ToLuaConversionError {
from: &'static str,
to: &'static str,
message: Option<String>,
},
UserDataTypeMismatch,
UserDataDestructed,
CallbackDestructed,
CallbackError {
traceback: String,
cause: Arc<Error>,
},
UserDataBorrowError,
UserDataBorrowMutError,
CoroutineUnresumable,
MismatchedRegistryKey,
RecursiveMutCallback,
PreviouslyResumedPanic,
ExternalError(Arc<dyn StdError + Send + Sync>),
}Expand description
Errors that can occur when interacting with the Lua engine.
The variant set mirrors the commonly used part of mlua’s Error. It is
marked #[non_exhaustive] (like mlua’s) so new variants can be added
without a breaking change.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
SyntaxError
A Lua syntax (compile/parse) error.
Fields
RuntimeError(String)
A Lua runtime error (error(..), a failed assert, a type error, or a
Rust callback returning Err).
MemoryError(String)
A memory allocation error reported by the VM.
FromLuaConversionError
A value could not be converted from a Lua value into the requested Rust type.
Fields
ToLuaConversionError
A Rust value could not be converted into a Lua value.
Fields
UserDataTypeMismatch
A UserData value was accessed as the wrong concrete type.
UserDataDestructed
A UserData value was used after it had been destructed (dropped).
CallbackDestructed
Either a callback or a userdata method was called, but the callback or userdata had been destructed.
This happens when a function/userdata created via Lua::scope is used
after the scope has ended (so the scope has already dropped the boxed
closure / invalidated the Lua object). Mirrors
mlua::Error::CallbackDestructed.
CallbackError
A Rust callback returned Err, which was raised as a Lua error and then
caught at a protected-call boundary (e.g. Function::call). The
original error is preserved in cause. Mirrors
mlua::Error::CallbackError.
luaur-rt only produces this variant for callback errors that carry
structured meaning across the Lua boundary (currently
Error::CallbackDestructed and Error::UserDataDestructed); plain
string callback errors continue to surface as Error::RuntimeError for
backward compatibility.
Fields
UserDataBorrowError
A UserData could not be immutably borrowed because it is already
mutably borrowed.
UserDataBorrowMutError
A UserData could not be mutably borrowed because it is already
borrowed.
CoroutineUnresumable
A coroutine (crate::Thread) could not be resumed because it has
finished, errored, or is currently running. Mirrors
mlua::Error::CoroutineUnresumable.
MismatchedRegistryKey
A crate::RegistryKey was used with a crate::Lua that does not
own it. Mirrors mlua::Error::MismatchedRegistryKey.
RecursiveMutCallback
A create_function_mut / create_userdata mutable callback was invoked
re-entrantly while a previous invocation still held the &mut. The inner
RefCell borrow failed, which we surface as this variant rather than
allowing mutable aliasing. Mirrors mlua::Error::RecursiveMutCallback.
PreviouslyResumedPanic
A Rust panic was raised across a pcall boundary, caught and resumed
once; a later attempt to re-raise/observe it failed because the panic was
already resumed. Mirrors mlua::Error::PreviouslyResumedPanic.
ExternalError(Arc<dyn StdError + Send + Sync>)
An error originating outside Lua, wrapped via Error::external.
Implementations§
Source§impl Error
impl Error
Sourcepub fn runtime<S: Display>(message: S) -> Self
pub fn runtime<S: Display>(message: S) -> Self
Create a Error::RuntimeError from any displayable message.
Mirrors mlua::Error::runtime.
Sourcepub fn downcast_ref<T: StdError + 'static>(&self) -> Option<&T>
pub fn downcast_ref<T: StdError + 'static>(&self) -> Option<&T>
Try to view the wrapped external error as a concrete type T.
Mirrors the common mlua::Error::downcast_ref use: only
Error::ExternalError carries a wrapped error to downcast.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn StdError + 'static)>
fn source(&self) -> Option<&(dyn StdError + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Auto Trait Implementations§
impl !RefUnwindSafe for Error
impl !UnwindSafe for Error
impl Freeze for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<E> ExternalError for E
impl<E> ExternalError for E
Source§fn into_lua_err(self) -> Error
fn into_lua_err(self) -> Error
self into an Error.