Skip to main content

tecton_core/
error.rs

1//! Unified error types for Tecton crates.
2
3use thiserror::Error;
4
5/// Convenient result alias used across the workspace.
6pub type Result<T> = std::result::Result<T, TectonError>;
7
8/// Top-level error type shared by storage, compute, and CLI layers.
9#[derive(Debug, Error)]
10pub enum TectonError {
11    #[error("configuration error: {0}")]
12    Config(String),
13
14    #[error("invalid input: {0}")]
15    InvalidInput(String),
16
17    #[error("not found: {0}")]
18    NotFound(String),
19
20    #[error("storage error: {0}")]
21    Storage(String),
22
23    #[error("compute error: {0}")]
24    Compute(String),
25
26    #[error("I/O error: {0}")]
27    Io(#[from] std::io::Error),
28
29    #[error("serialization error: {0}")]
30    Serde(#[from] serde_json::Error),
31
32    #[error("internal error: {0}")]
33    Internal(String),
34}
35
36impl TectonError {
37    /// Build a configuration error from any displayable value.
38    pub fn config(msg: impl Into<String>) -> Self {
39        Self::Config(msg.into())
40    }
41
42    /// Build an invalid-input error (used for CLI/API validation).
43    pub fn invalid_input(msg: impl Into<String>) -> Self {
44        Self::InvalidInput(msg.into())
45    }
46
47    /// Build a storage-layer error.
48    pub fn storage(msg: impl Into<String>) -> Self {
49        Self::Storage(msg.into())
50    }
51
52    /// Build a compute-layer error.
53    pub fn compute(msg: impl Into<String>) -> Self {
54        Self::Compute(msg.into())
55    }
56}