Skip to main content

base_scheduler/
task_error.rs

1// Released under the MIT License.
2// Copyright, 2026, by Samuel Williams.
3
4use std::{any::Any, fmt};
5
6/// A task ended without producing its normal output.
7#[derive(Debug)]
8pub enum TaskError {
9    /// The future was destroyed or the blocking closure was skipped before execution.
10    Cancelled,
11    /// Polling a future or executing a blocking closure panicked. The original payload is retained for the caller.
12    Panicked(Box<dyn Any + Send + 'static>),
13}
14
15impl fmt::Display for TaskError {
16    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
17        match self {
18            Self::Cancelled => formatter.write_str("task cancelled"),
19            Self::Panicked(_) => formatter.write_str("task panicked"),
20        }
21    }
22}
23
24impl std::error::Error for TaskError {}