pub struct PanicInfo { /* private fields */ }
Expand description
Represents a panic caugh across processes.
This contains the marshalled panic information so that it can be used for other purposes.
This is similar to std::panic::PanicInfo
but can cross process boundaries.
Implementations§
source§impl PanicInfo
impl PanicInfo
sourcepub fn message(&self) -> &str
pub fn message(&self) -> &str
Returns the message of the panic.
Examples found in repository?
examples/panic.rs (line 14)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
fn main() {
procspawn::init();
let handle = spawn((), |()| {
panic!("Whatever!");
});
match handle.join() {
Ok(()) => unreachable!(),
Err(err) => {
let panic = err.panic_info().expect("got a non panic error");
println!("process panicked with {}", panic.message());
println!("{:#?}", panic);
}
}
}
More examples
examples/pool.rs (line 23)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
fn main() {
procspawn::init();
let pool = Pool::new(4).unwrap();
let mut handles = vec![];
for counter in 0..8 {
handles.push(procspawn::spawn!(in pool, (counter) || {
thread::sleep(Duration::from_millis(500));
counter
}));
}
for handle in handles {
match handle.join() {
Ok(val) => println!("got result: {}", val),
Err(err) => {
let panic = err.panic_info().expect("got a non panic error");
println!("process panicked with {}", panic.message());
println!("{:#?}", panic);
}
}
}
pool.shutdown();
}
Trait Implementations§
source§impl<'de> Deserialize<'de> for PanicInfo
impl<'de> Deserialize<'de> for PanicInfo
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl From<PanicInfo> for SpawnError
impl From<PanicInfo> for SpawnError
source§fn from(panic: PanicInfo) -> SpawnError
fn from(panic: PanicInfo) -> SpawnError
Converts to this type from the input type.
Auto Trait Implementations§
impl RefUnwindSafe for PanicInfo
impl Send for PanicInfo
impl Sync for PanicInfo
impl Unpin for PanicInfo
impl UnwindSafe for PanicInfo
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