Enum rquickjs_core::Error
source · [−]#[non_exhaustive]
pub enum Error {
Allocation,
InvalidString(NulError),
Utf8(Utf8Error),
Io(IoError),
Exception {
message: StdString,
file: StdString,
line: i32,
stack: StdString,
},
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.
InvalidString(NulError)
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.
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
UnrelatedRuntime
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
sourceimpl Error
impl Error
sourcepub fn new_resolving<B, N>(base: B, name: N) -> Self where
StdString: From<B> + From<N>,
pub fn new_resolving<B, N>(base: B, name: N) -> Self where
StdString: From<B> + From<N>,
Create resolving error
sourcepub fn new_resolving_message<B, N, M>(base: B, name: N, msg: M) -> Self where
StdString: From<B> + From<N> + From<M>,
pub fn new_resolving_message<B, N, M>(base: B, name: N, msg: M) -> Self where
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) -> Self where
StdString: From<N>,
pub fn new_loading<N>(name: N) -> Self where
StdString: From<N>,
Create loading error
sourcepub fn new_loading_message<N, M>(name: N, msg: M) -> Self where
StdString: From<N> + From<M>,
pub fn new_loading_message<N, M>(name: N, msg: M) -> Self where
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
) -> Self where
StdString: From<M>,
pub fn new_from_js_message<M>(
from: &'static str,
to: &'static str,
msg: M
) -> Self where
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
) -> Self where
StdString: From<M>,
pub fn new_into_js_message<M>(
from: &'static str,
to: &'static str,
msg: M
) -> Self where
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
Trait Implementations
sourceimpl Error for Error
impl Error for Error
1.30.0 · sourcefn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
1.0.0 · sourcefn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
sourceimpl From<FromUtf8Error> for Error
impl From<FromUtf8Error> for Error
sourcefn from(error: FromUtf8Error) -> Self
fn from(error: FromUtf8Error) -> Self
Converts to this type from the input type.
Auto Trait Implementations
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl !UnwindSafe for Error
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more