tecton-core 0.1.0

Shared utilities, configuration, logging, and types for Tecton
Documentation
//! Unified error types for Tecton crates.

use thiserror::Error;

/// Convenient result alias used across the workspace.
pub type Result<T> = std::result::Result<T, TectonError>;

/// Top-level error type shared by storage, compute, and CLI layers.
#[derive(Debug, Error)]
pub enum TectonError {
    #[error("configuration error: {0}")]
    Config(String),

    #[error("invalid input: {0}")]
    InvalidInput(String),

    #[error("not found: {0}")]
    NotFound(String),

    #[error("storage error: {0}")]
    Storage(String),

    #[error("compute error: {0}")]
    Compute(String),

    #[error("I/O error: {0}")]
    Io(#[from] std::io::Error),

    #[error("serialization error: {0}")]
    Serde(#[from] serde_json::Error),

    #[error("internal error: {0}")]
    Internal(String),
}

impl TectonError {
    /// Build a configuration error from any displayable value.
    pub fn config(msg: impl Into<String>) -> Self {
        Self::Config(msg.into())
    }

    /// Build an invalid-input error (used for CLI/API validation).
    pub fn invalid_input(msg: impl Into<String>) -> Self {
        Self::InvalidInput(msg.into())
    }

    /// Build a storage-layer error.
    pub fn storage(msg: impl Into<String>) -> Self {
        Self::Storage(msg.into())
    }

    /// Build a compute-layer error.
    pub fn compute(msg: impl Into<String>) -> Self {
        Self::Compute(msg.into())
    }
}