Enum rquickjs_core::Error
source · #[non_exhaustive]pub enum Error {
Show 18 variants
Allocation,
DuplicateExports,
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,
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.
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.
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