Enum rquickjs_core::Error
source · #[non_exhaustive]pub enum Error {
Show 14 variants
Allocation,
DuplicateExports,
InvalidString(NulError),
InvalidCStr(FromBytesWithNulError),
Utf8(Utf8Error),
Io(IoError),
Exception,
FromJs {
from: &'static str,
to: &'static str,
message: Option<StdString>,
},
IntoJs {
from: &'static str,
to: &'static str,
message: Option<StdString>,
},
NumArgs {
expected: Range<usize>,
given: usize,
},
Resolving {
base: StdString,
name: StdString,
message: Option<StdString>,
},
Loading {
name: StdString,
message: Option<StdString>,
},
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(IoError)
An io error
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.
NumArgs
Error matching of function arguments
Resolving
Error when resolving js module
Loading
Error when loading js module
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) -> Selfwhere
StdString: From<B> + From<N>,
pub fn new_resolving<B, N>(base: B, name: N) -> Selfwhere StdString: From<B> + From<N>,
Create resolving error
sourcepub fn new_resolving_message<B, N, M>(base: B, name: N, msg: M) -> Selfwhere
StdString: From<B> + From<N> + From<M>,
pub fn new_resolving_message<B, N, M>(base: B, name: N, msg: M) -> Selfwhere StdString: From<B> + From<N> + From<M>,
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) -> Selfwhere
StdString: From<N>,
pub fn new_loading<N>(name: N) -> Selfwhere StdString: From<N>,
Create loading error
sourcepub fn new_loading_message<N, M>(name: N, msg: M) -> Selfwhere
StdString: From<N> + From<M>,
pub fn new_loading_message<N, M>(name: N, msg: M) -> Selfwhere StdString: From<N> + From<M>,
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
) -> Selfwhere
StdString: From<M>,
pub fn new_from_js_message<M>( from: &'static str, to: &'static str, msg: M ) -> Selfwhere StdString: From<M>,
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
) -> Selfwhere
StdString: From<M>,
pub fn new_into_js_message<M>( from: &'static str, to: &'static str, msg: M ) -> Selfwhere StdString: From<M>,
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 new_num_args(expected: Range<usize>, given: usize) -> Self
pub fn new_num_args(expected: Range<usize>, given: usize) -> Self
Create function args mismatch 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