use thiserror::Error;
pub type Result<T> = std::result::Result<T, TectonError>;
#[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 {
pub fn config(msg: impl Into<String>) -> Self {
Self::Config(msg.into())
}
pub fn invalid_input(msg: impl Into<String>) -> Self {
Self::InvalidInput(msg.into())
}
pub fn storage(msg: impl Into<String>) -> Self {
Self::Storage(msg.into())
}
pub fn compute(msg: impl Into<String>) -> Self {
Self::Compute(msg.into())
}
}