Skip to main content

crackle_runtime/
error.rs

1use std::fmt;
2
3/// Errors that can occur during crackle runtime operations.
4#[derive(Debug)]
5pub enum CrackleError {
6    /// A task panicked during firing.
7    TaskPanicked(String),
8    /// The kiln was already cooled and cannot accept new tasks.
9    KilnCooled,
10    /// Invalid thermal profile configuration.
11    InvalidProfile(String),
12    /// Pattern detection failed.
13    DetectionFailed(String),
14}
15
16impl fmt::Display for CrackleError {
17    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18        match self {
19            CrackleError::TaskPanicked(msg) => write!(f, "task panicked: {msg}"),
20            CrackleError::KilnCooled => write!(f, "kiln has already cooled and cannot accept new tasks"),
21            CrackleError::InvalidProfile(msg) => write!(f, "invalid thermal profile: {msg}"),
22            CrackleError::DetectionFailed(msg) => write!(f, "pattern detection failed: {msg}"),
23        }
24    }
25}
26
27impl std::error::Error for CrackleError {}
28
29/// A specialized result type for crackle runtime operations.
30pub type Result<T> = std::result::Result<T, CrackleError>;