Enum rquickjs::Error

source ·
#[non_exhaustive]
pub enum Error {
Show 20 variants Allocation, DuplicateExports, InvalidExport, InvalidString(NulError), InvalidCStr(FromBytesWithNulError), Utf8(Utf8Error), Io(Error), ClassBorrow(BorrowError), FunctionBorrow(BorrowError), Exception, FromJs { from: &'static str, to: &'static str, message: Option<String>, }, IntoJs { from: &'static str, to: &'static str, message: Option<String>, }, MissingArgs { expected: usize, given: usize, }, TooManyArgs { expected: usize, given: usize, }, Resolving { base: String, name: String, message: Option<String>, }, Loading { name: String, message: Option<String>, }, AsSlice(AsSliceError), UnrelatedRuntime, WouldBlock, Unknown,
}
Expand description

Error type of the library.

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.
§

Allocation

Could not allocate memory This is generally only triggered when out of memory.

§

DuplicateExports

A module defined two exported values with the same name.

§

InvalidExport

Tried to export a entry which was not previously declared.

§

InvalidString(NulError)

Found a string with a internal null byte while converting to C string.

§

InvalidCStr(FromBytesWithNulError)

Found a string with a internal null byte while converting to C string.

§

Utf8(Utf8Error)

String from rquickjs was not UTF-8

§

Io(Error)

An io error

§

ClassBorrow(BorrowError)

An error happened while trying to borrow a Rust class object.

§

FunctionBorrow(BorrowError)

An error happened while trying to borrow a Rust function.

§

Exception

An exception raised by QuickJS itself. The actual JavaScript value can be retrieved by calling Ctx::catch.

When returned from a callback the JavaScript will continue to unwind with the current error.

§

FromJs

Error converting from JavaScript to a Rust type.

Fields

§from: &'static str
§to: &'static str
§message: Option<String>
§

IntoJs

Error converting to JavaScript from a Rust type.

Fields

§from: &'static str
§to: &'static str
§message: Option<String>
§

MissingArgs

Error matching of function arguments

Fields

§expected: usize
§given: usize
§

TooManyArgs

Fields

§expected: usize
§given: usize
§

Resolving

Error when resolving js module

Fields

§base: String
§name: String
§message: Option<String>
§

Loading

Error when loading js module

Fields

§name: String
§message: Option<String>
§

AsSlice(AsSliceError)

§

UnrelatedRuntime

Error when restoring a Persistent in a runtime other than the original runtime.

§

WouldBlock

An error returned by a blocked on promise if block on the promise would result in a dead lock.

§

Unknown

An error from QuickJS from which the specifics are unknown. Should eventually be removed as development progresses.

Implementations§

source§

impl Error

source

pub fn new_resolving<B, N>(base: B, name: N) -> Error
where String: From<B> + From<N>,

Create resolving error

source

pub fn new_resolving_message<B, N, M>(base: B, name: N, msg: M) -> Error
where String: From<B> + From<N> + From<M>,

Create resolving error with message

source

pub fn is_resolving(&self) -> bool

Returns whether the error is a resolving error

source

pub fn new_loading<N>(name: N) -> Error
where String: From<N>,

Create loading error

source

pub fn new_loading_message<N, M>(name: N, msg: M) -> Error
where String: From<N> + From<M>,

Create loading error

source

pub fn is_loading(&self) -> bool

Returns whether the error is a loading error

source

pub fn is_exception(&self) -> bool

Returns whether the error is a QuickJS generated exception.

source

pub fn new_from_js(from: &'static str, to: &'static str) -> Error

Create from JS conversion error

source

pub fn new_from_js_message<M>( from: &'static str, to: &'static str, msg: M ) -> Error
where String: From<M>,

Create from JS conversion error with message

source

pub fn new_into_js(from: &'static str, to: &'static str) -> Error

Create into JS conversion error

source

pub fn new_into_js_message<M>( from: &'static str, to: &'static str, msg: M ) -> Error
where String: From<M>,

Create into JS conversion error with message

source

pub fn is_from_js(&self) -> bool

Returns whether the error is a from JS conversion error

source

pub fn is_from_js_to_js(&self) -> bool

Returns whether the error is a from JS to JS type conversion error

source

pub fn is_into_js(&self) -> bool

Returns whether the error is an into JS conversion error

source

pub fn is_num_args(&self) -> bool

Return whether the error is an function args mismatch error

Trait Implementations§

source§

impl Debug for Error

source§

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

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

impl Display for Error

source§

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

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

impl Error for Error

1.30.0 · source§

fn source(&self) -> Option<&(dyn Error + 'static)>

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<AsSliceError> for Error

source§

fn from(value: AsSliceError) -> Error

Converts to this type from the input type.
source§

impl From<Error> for Error

source§

fn from(error: Error) -> Error

Converts to this type from the input type.
source§

impl From<FromBytesWithNulError> for Error

source§

fn from(error: FromBytesWithNulError) -> Error

Converts to this type from the input type.
source§

impl From<FromUtf8Error> for Error

source§

fn from(error: FromUtf8Error) -> Error

Converts to this type from the input type.
source§

impl From<NulError> for Error

source§

fn from(error: NulError) -> Error

Converts to this type from the input type.
source§

impl From<Utf8Error> for Error

source§

fn from(error: Utf8Error) -> Error

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Error

§

impl !RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl !UnwindSafe 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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default 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>,

§

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>,

§

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.
source§

impl<T> ParallelSend for T
where T: Send,