error-engine 0.1.0

A message catalog + presentation layer on top of thiserror and tracing for consistent error/warning/info rendering.
Documentation
use error_engine::{Catalog, Engine, EngineDiagnostic, Severity};
use error_engine::thiserror::Error;

#[derive(Debug, Error)]
enum AppError {
    #[error("config not found")]
    ConfigNotFound { path: String },
}

impl EngineDiagnostic for AppError {
    fn code(&self) -> &'static str {
        match self {
            AppError::ConfigNotFound { .. } => "CONFIG_NOT_FOUND",
        }
    }
    fn severity(&self) -> Severity {
        Severity::Error
    }
    fn context(&self) -> Vec<(&'static str, String)> {
        match self {
            AppError::ConfigNotFound { path } => vec![("path", path.clone())],
        }
    }
}

fn main() -> anyhow::Result<()> {
    tracing_subscriber::fmt::init();

    // Infallible: a missing/broken errors.toml never stops the app —
    // diagnostics will just render as UNK-000 until it's fixed.
    let catalog = Catalog::load_or_fallback("examples/errors.toml");
    let engine = Engine::new(catalog);

    let err = AppError::ConfigNotFound { path: "/etc/app.toml".into() };
    println!("{}", engine.message(&err));
    engine.log(&err);
    Ok(())
}