Enum rquickjs_core::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
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.
IntoJs
Error converting to JavaScript from a Rust type.
MissingArgs
Error matching of function arguments
TooManyArgs
Resolving
Error when resolving js module
Loading
Error when loading js module
AsSlice(AsSliceError)
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
impl Error
sourcepub fn new_resolving<B, N>(base: B, name: N) -> Self
pub fn new_resolving<B, N>(base: B, name: N) -> Self
Create resolving error
sourcepub fn new_resolving_message<B, N, M>(base: B, name: N, msg: M) -> Self
pub fn new_resolving_message<B, N, M>(base: B, name: N, msg: M) -> Self
Create resolving error with message
sourcepub fn is_resolving(&self) -> bool
pub fn is_resolving(&self) -> bool
Returns whether the error is a resolving error
sourcepub fn new_loading<N>(name: N) -> Self
pub fn new_loading<N>(name: N) -> Self
Create loading error
sourcepub fn new_loading_message<N, M>(name: N, msg: M) -> Self
pub fn new_loading_message<N, M>(name: N, msg: M) -> Self
Create loading error
sourcepub fn is_loading(&self) -> bool
pub fn is_loading(&self) -> bool
Returns whether the error is a loading error
sourcepub fn is_exception(&self) -> bool
pub fn is_exception(&self) -> bool
Returns whether the error is a QuickJS generated exception.
sourcepub fn new_from_js(from: &'static str, to: &'static str) -> Self
pub fn new_from_js(from: &'static str, to: &'static str) -> Self
Create from JS conversion error
sourcepub fn new_from_js_message<M>(
from: &'static str,
to: &'static str,
msg: M
) -> Self
pub fn new_from_js_message<M>( from: &'static str, to: &'static str, msg: M ) -> Self
Create from JS conversion error with message
sourcepub fn new_into_js(from: &'static str, to: &'static str) -> Self
pub fn new_into_js(from: &'static str, to: &'static str) -> Self
Create into JS conversion error
sourcepub fn new_into_js_message<M>(
from: &'static str,
to: &'static str,
msg: M
) -> Self
pub fn new_into_js_message<M>( from: &'static str, to: &'static str, msg: M ) -> Self
Create into JS conversion error with message
sourcepub fn is_from_js(&self) -> bool
pub fn is_from_js(&self) -> bool
Returns whether the error is a from JS conversion error
sourcepub fn is_from_js_to_js(&self) -> bool
pub fn is_from_js_to_js(&self) -> bool
Returns whether the error is a from JS to JS type conversion error
sourcepub fn is_into_js(&self) -> bool
pub fn is_into_js(&self) -> bool
Returns whether the error is an into JS conversion error
sourcepub fn is_num_args(&self) -> bool
pub fn is_num_args(&self) -> bool
Return whether the error is an function args mismatch error
Trait Implementations§
source§impl Error for Error
impl Error for Error
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
source§impl From<FromBytesWithNulError> for Error
impl From<FromBytesWithNulError> for Error
source§fn from(error: FromBytesWithNulError) -> Self
fn from(error: FromBytesWithNulError) -> Self
source§impl From<FromUtf8Error> for Error
impl From<FromUtf8Error> for Error
source§fn from(error: FromUtf8Error) -> Self
fn from(error: FromUtf8Error) -> Self
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> 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> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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