Struct JoinError

struct JoinError { ... }

Task failed to execute to completion.

Implementations

impl JoinError

fn is_cancelled(self: &Self) -> bool

Returns 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: &Self) -> bool

Returns true if the error was caused by the task panicking.

Examples

use std::panic;

#[tokio::main]
async fn main() {
    let err = tokio::spawn(async {
        panic!("boom");
    }).await.unwrap_err();

    assert!(err.is_panic());
}
fn into_panic(self: Self) -> Box<dyn Any + Send + 'static>

Consumes the join error, returning the object with which the task panicked.

Panics

into_panic() panics if the Error does not represent the underlying task terminating with a panic. Use is_panic to check the error reason or try_into_panic for 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: 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, self is 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: &Self) -> Id

Returns a task ID that identifies the task which errored relative to other currently spawned tasks.

impl Debug for JoinError

fn fmt(self: &Self, fmt: &mut Formatter<'_>) -> Result

impl Display for JoinError

fn fmt(self: &Self, fmt: &mut Formatter<'_>) -> Result

impl Error for JoinError

impl Freeze for JoinError

impl RefUnwindSafe for JoinError

impl Send for JoinError

impl Sync for JoinError

impl Unpin for JoinError

impl UnsafeUnpin for JoinError

impl UnwindSafe for JoinError

impl<T> Any for JoinError

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for JoinError

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for JoinError

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> From for JoinError

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToString for JoinError

fn to_string(self: &Self) -> String

impl<T, U> Into for JoinError

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for JoinError

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for JoinError

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>