Struct procspawn::SpawnError
source · pub struct SpawnError { /* private fields */ }
Expand description
Encapsulates errors of the procspawn crate.
In particular it gives access to remotely captured panics.
Implementations§
source§impl SpawnError
impl SpawnError
sourcepub fn panic_info(&self) -> Option<&PanicInfo>
pub fn panic_info(&self) -> Option<&PanicInfo>
If a panic ocurred this returns the captured panic info.
Examples found in repository?
examples/panic.rs (line 13)
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 22)
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();
}
sourcepub fn is_cancellation(&self) -> bool
pub fn is_cancellation(&self) -> bool
True if this error indicates a cancellation.
sourcepub fn is_timeout(&self) -> bool
pub fn is_timeout(&self) -> bool
True if this error indicates a timeout.
sourcepub fn is_remote_close(&self) -> bool
pub fn is_remote_close(&self) -> bool
True if this means the remote side closed.
Trait Implementations§
source§impl Debug for SpawnError
impl Debug for SpawnError
source§impl Display for SpawnError
impl Display for SpawnError
source§impl Error for SpawnError
impl Error for SpawnError
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()
source§impl From<Box<ErrorKind, Global>> for SpawnError
impl From<Box<ErrorKind, Global>> for SpawnError
source§fn from(err: BincodeError) -> SpawnError
fn from(err: BincodeError) -> SpawnError
Converts to this type from the input type.
source§impl From<Error> for SpawnError
impl From<Error> for SpawnError
source§fn from(err: Error) -> SpawnError
fn from(err: Error) -> SpawnError
Converts to this type from the input type.
source§impl From<IpcError> for SpawnError
impl From<IpcError> for SpawnError
source§fn from(err: IpcError) -> SpawnError
fn from(err: IpcError) -> SpawnError
Converts to this type from the input type.
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.
source§impl From<TryRecvError> for SpawnError
impl From<TryRecvError> for SpawnError
source§fn from(err: TryRecvError) -> SpawnError
fn from(err: TryRecvError) -> SpawnError
Converts to this type from the input type.
Auto Trait Implementations§
impl !RefUnwindSafe for SpawnError
impl Send for SpawnError
impl Sync for SpawnError
impl Unpin for SpawnError
impl !UnwindSafe for SpawnError
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