pub struct Panic(/* private fields */);
Expand description
An error representing a panic carrying the message as payload.
To capture panics, register the hook using set_panic_hook
.
§Example
use relay_ffi::{catch_unwind, with_last_error, Panic};
#[catch_unwind]
unsafe fn panics() {
panic!("this is fine");
}
relay_ffi::set_panic_hook();
unsafe { panics() };
with_last_error(|error| {
if let Some(panic) = error.downcast_ref::<Panic>() {
println!("{}", panic.description());
}
});
Implementations§
Trait Implementations§
source§impl Error for Panic
impl Error for Panic
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns 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 Freeze for Panic
impl RefUnwindSafe for Panic
impl Send for Panic
impl Sync for Panic
impl Unpin for Panic
impl UnwindSafe for Panic
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