luminal/runtime/
error.rs

1//! Error types for the Luminal runtime
2//!
3//! This module defines the error types that can occur during
4//! task execution and management within the Luminal runtime.
5
6use std::fmt;
7
8/// Errors that can occur when working with tasks in the runtime
9///
10/// These represent the various failure modes that can occur when 
11/// scheduling, executing, or awaiting tasks.
12#[derive(Debug)]
13pub enum TaskError {
14    /// The channel used to communicate with a task has been disconnected
15    ///
16    /// This typically occurs when a task or its handle is dropped
17    /// before the task completes.
18    Disconnected,
19    
20    /// A timeout occurred while waiting for a task to complete
21    ///
22    /// This can happen when using timeouts with task execution or
23    /// when the runtime's block_on method times out.
24    Timeout,
25    
26    /// The task panicked during execution
27    ///
28    /// This error is produced when a task panics during its execution.
29    /// The runtime attempts to capture and propagate this error safely.
30    Panicked,
31}
32
33impl fmt::Display for TaskError {
34    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
35        match self {
36            TaskError::Disconnected => write!(f, "Task channel disconnected"),
37            TaskError::Timeout => write!(f, "Task timed out"),
38            TaskError::Panicked => write!(f, "Task panicked"),
39        }
40    }
41}
42
43impl std::error::Error for TaskError {}