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