Struct JoinError
pub struct JoinError { /* private fields */ }
Task failed to execute to completion.
Implementations
impl JoinError
fn is_cancelled(&self) -> boolReturns true if the error was caused by the task being cancelled.
See the module level docs for more information on cancellation.
fn is_panic(&self) -> boolReturns true if the error was caused by the task panicking.
Examples
# #fn into_panic(self) -> Box<dyn Any + Send + 'static>Consumes the join error, returning the object with which the task panicked.
Panics
into_panic()panics if theErrordoes not represent the underlying task terminating with a panic. Useis_panicto check the error reason ortry_into_panicfor a variant that does not panic.Examples
use std::panic; #[tokio::main] async fn main() { let err = tokio::spawn(async { panic!("boom"); }).await.unwrap_err(); if err.is_panic() { // Resume the panic on the main task panic::resume_unwind(err.into_panic()); } }fn try_into_panic(self) -> Result<Box<dyn Any + Send + 'static>, JoinError>Consumes the join error, returning the object with which the task panicked if the task terminated due to a panic. Otherwise,
selfis returned.Examples
use std::panic; #[tokio::main] async fn main() { let err = tokio::spawn(async { panic!("boom"); }).await.unwrap_err(); if let Ok(reason) = err.try_into_panic() { // Resume the panic on the main task panic::resume_unwind(reason); } }fn id(&self) -> IdReturns a task ID that identifies the task which errored relative to other currently spawned tasks.
Trait Implementations
impl Debug for JoinError
fn fmt(&self, fmt: &mut Formatter<'_>) -> Result
impl Display for JoinError
fn fmt(&self, fmt: &mut Formatter<'_>) -> Result
impl Error for JoinError
Auto Trait Implementations
impl !RefUnwindSafe for JoinError
impl !UnwindSafe for JoinError
impl Freeze for JoinError
impl Send for JoinError
impl Sync for JoinError
impl Unpin for JoinError
impl UnsafeUnpin for JoinError
Blanket Implementations
impl<T> Any for JoinError
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for JoinError
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for JoinError
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for JoinError
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToString for JoinError
where
T: Display + ?Sized,
fn to_string(&self) -> String
impl<T, U> Into<U> for JoinError
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for JoinError
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for JoinError
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>