Skip to main content

Error

Enum Error 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

SyntaxError

A Lua syntax (compile/parse) error.

Fields

§message: String

The human-readable message produced by the compiler.

§incomplete_input: bool

Whether the input looked like it was merely incomplete (e.g. an unterminated block). Always false for now; reserved for REPL use.

§

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

§from: &'static str

The Lua type name of the source value.

§to: String

The name of the target Rust type.

§message: Option<String>

Optional extra detail.

§

ToLuaConversionError

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

Fields

§from: &'static str

The name of the source Rust type.

§to: &'static str

The Lua type name being targeted.

§message: Option<String>

Optional extra detail.

§

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

§traceback: String

A Lua call-stack traceback (empty when luaur-rt does not capture one).

§cause: Arc<Error>

The original error returned by the Rust callback.

§

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

Source

pub fn runtime<S: Display>(message: S) -> Self

Create a Error::RuntimeError from any displayable message.

Mirrors mlua::Error::runtime.

Source

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.

Source

pub fn external<T: Into<Box<dyn StdError + Send + Sync>>>(err: T) -> Self

Wrap an arbitrary std::error::Error as an Error::ExternalError.

Mirrors mlua::Error::external: if the input is already a luaur Error, it is preserved as-is rather than re-wrapped.

Trait Implementations§

Source§

impl Clone for Error

Source§

fn clone(&self) -> Error

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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

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

impl Display for Error

Source§

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

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

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn StdError + '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 From<&str> for Error

Source§

fn from(msg: &str) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Error

Source§

fn from(msg: String) -> Self

Converts to this type from the input type.
Source§

impl FromLua for Error

Source§

fn from_lua(value: Value, _lua: &Lua) -> Result<Self>

Perform the conversion.
Source§

fn from_lua_arg( arg: Value, _i: usize, _to: Option<&str>, lua: &Lua, ) -> Result<Self>

Convert an argument at 1-based position i. The default forwards to FromLua::from_lua; specific impls can produce nicer messages. Mirrors mlua::FromLua::from_lua_arg.
Source§

impl IntoLua for Error

Source§

fn into_lua(self, _lua: &Lua) -> Result<Value>

Perform the conversion.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
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 + Sync + Send>>,

Source§

fn into_lua_err(self) -> Error

Convert self into an Error.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_lua_multi(values: MultiValue, lua: &Lua) -> Result<T, Error>

Perform the conversion.
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<T> IntoLuaMulti for T
where T: IntoLua,

Source§

fn into_lua_multi(self, lua: &Lua) -> Result<MultiValue, Error>

Perform the conversion.
Source§

impl<T> MaybeSend for T

Source§

impl<T> MaybeSync for T

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.