sword-core 0.2.1

Structured web framework built on top of tokio ecosystem, providing powerful features for building robust web applications.
Documentation
use thiserror::Error;

#[derive(Debug, Error)]
pub enum ConfigError {
    #[error("Configuration file not found at config/config.toml")]
    FileNotFound,

    #[error("Failed to read configuration file: {source}")]
    ReadError {
        #[from]
        source: std::io::Error,
    },

    #[error("Environment variable interpolation error: {message}")]
    InterpolationError { message: String },

    #[error("Configuration key '{key}' not found")]
    KeyNotFound { key: String },

    #[error("Deserialization error: {source}")]
    DeserializeError {
        #[from]
        source: toml::de::Error,
    },
}

impl ConfigError {
    pub fn interpolation_error(message: String) -> Self {
        ConfigError::InterpolationError { message }
    }

    pub fn key_not_found(key: impl Into<String>) -> Self {
        ConfigError::KeyNotFound { key: key.into() }
    }
}