1use std::fmt;
2#[cfg(feature = "serde")]
3use serde::{Serialize, Deserialize};
4
5#[derive(Debug)]
7#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
8pub enum CrackleError {
9 TaskPanicked(String),
11 KilnCooled,
13 InvalidProfile(String),
15 DetectionFailed(String),
17}
18
19impl fmt::Display for CrackleError {
20 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21 match self {
22 CrackleError::TaskPanicked(msg) => write!(f, "task panicked: {msg}"),
23 CrackleError::KilnCooled => write!(f, "kiln has already cooled and cannot accept new tasks"),
24 CrackleError::InvalidProfile(msg) => write!(f, "invalid thermal profile: {msg}"),
25 CrackleError::DetectionFailed(msg) => write!(f, "pattern detection failed: {msg}"),
26 }
27 }
28}
29
30impl std::error::Error for CrackleError {}
31
32pub type Result<T> = std::result::Result<T, CrackleError>;