//! General error type that the CLI propagates. //! //! `AppError` aggregates all error kinds that may surface during a command //! execution: parsing, I/O, epoch logic, storage, and a catch-all. #![warn(missing_docs, clippy::missing_docs_in_private_items)] use lib_efo::{ error::{EpochError, StorageError}, repository_format::FormatError, transaction::TransactionError, workspace::WorkspaceError, worldgen::WorldGenError, }; use miette::Diagnostic; use thiserror::Error; /// All errors that can bubble up to the CLI. #[derive(Debug, Error, Diagnostic)] pub enum AppError { /// Generic “invalid command / missing flag” - emitted by clap. #[error("Command-line error: {0}")] // #[diagnostic(transparent)] Clap(#[from] clap::Error), /// Errors that happen when reading / writing the JSON file. #[error("I/O error: {0}")] // #[diagnostic(transparent)] Io(#[from] std::io::Error), /// Domain-specific problems (see `EpochError`). #[error("Epoch error:")] #[diagnostic(transparent)] Epoch(#[from] EpochError), /// Storage-layer (e.g. DB) errors. #[error("Storage error: {0}")] // #[diagnostic(transparent)] Storage(#[from] StorageError), /// Exclusive locking or interrupted-write recovery failed safely. #[error("Repository safety check stopped: {0}")] Transaction(#[from] TransactionError), /// Format-2 state is missing, inconsistent, or unsafe to change. #[error("Repository state error: {0}")] Workspace(#[from] WorkspaceError), /// Repository manifest format detection failed. #[error("Repository format error: {0}")] Format(#[from] FormatError), /// World-generation configuration or validation failed. #[error("World generation stopped: {0}")] WorldGen(#[from] WorldGenError), // /// Anything else we didn't anticipate. // #[error("Unknown error: {0}")] // Other(String), }