Enum rquickjs::CaughtError
source · pub enum CaughtError<'js> {
Error(Error),
Exception(Exception<'js>),
Value(Value<'js>),
}
Expand description
An error type containing possible thrown exception values.
Variants§
Error(Error)
Error wasn’t an exception
Exception(Exception<'js>)
Error was an exception and an instance of Error
Value(Value<'js>)
Error was an exception but not an instance of Error.
Implementations§
source§impl<'js> CaughtError<'js>
impl<'js> CaughtError<'js>
sourcepub fn from_error(ctx: &Ctx<'js>, error: Error) -> CaughtError<'js>
pub fn from_error(ctx: &Ctx<'js>, error: Error) -> CaughtError<'js>
Create a CaughtError
from an Error
, retrieving the error value from Ctx
if there
was one.
sourcepub fn catch<T>(
ctx: &Ctx<'js>,
error: Result<T, Error>
) -> Result<T, CaughtError<'js>>
pub fn catch<T>( ctx: &Ctx<'js>, error: Result<T, Error> ) -> Result<T, CaughtError<'js>>
Turn a Result
with Error
into a result with CaughtError
retrieving the error
value from the context if there was one.
sourcepub fn throw(self, ctx: &Ctx<'js>) -> Error
pub fn throw(self, ctx: &Ctx<'js>) -> Error
Put the possible caught value back as the current error and turn the CaughtError
into Error
sourcepub fn is_exception(&self) -> bool
pub fn is_exception(&self) -> bool
Returns whether self is of variant CaughtError::Exception
.
sourcepub fn is_js_error(&self) -> bool
pub fn is_js_error(&self) -> bool
Returns whether self is of variant CaughtError::Exception
or CaughtError::Value
.
Trait Implementations§
source§impl<'js> Debug for CaughtError<'js>
impl<'js> Debug for CaughtError<'js>
source§impl<'js> Display for CaughtError<'js>
impl<'js> Display for CaughtError<'js>
source§impl<'js> Error for CaughtError<'js>
impl<'js> Error for CaughtError<'js>
1.30.0 · source§fn 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 · source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl<'js> !RefUnwindSafe for CaughtError<'js>
impl<'js> !Send for CaughtError<'js>
impl<'js> !Sync for CaughtError<'js>
impl<'js> Unpin for CaughtError<'js>
impl<'js> !UnwindSafe for CaughtError<'js>
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
Mutably borrows from an owned value. Read more