bin_efo/
error.rs

1//! General error type that the CLI propagates.
2//!
3//! `AppError` aggregates all error kinds that may surface during a command
4//! execution: parsing, I/O, epoch logic, storage, and a catch-all.
5
6#![warn(missing_docs, clippy::missing_docs_in_private_items)]
7
8use lib_efo::error::{EpochError, StorageError};
9use miette::Diagnostic;
10use thiserror::Error;
11
12/// All errors that can bubble up to the CLI.
13#[derive(Debug, Error, Diagnostic)]
14#[allow(dead_code)]
15pub enum AppError {
16    /// Generic “invalid command / missing flag” - emitted by clap.
17    #[error("Command-line error: {0}")]
18    // #[diagnostic(transparent)]
19    Clap(#[from] clap::Error),
20
21    /// Errors that happen when reading / writing the JSON file.
22    #[error("I/O error: {0}")]
23    // #[diagnostic(transparent)]
24    Io(#[from] std::io::Error),
25
26    /// Domain-specific problems (see `EpochError`).
27    #[error("Epoch error:")]
28    #[diagnostic(transparent)]
29    Epoch(#[from] EpochError),
30
31    /// Storage-layer (e.g. DB) errors.
32    #[error("Storage error: {0}")]
33    // #[diagnostic(transparent)]
34    Storage(#[from] StorageError),
35
36    /// Anything else we didn't anticipate.
37    #[error("Unknown error: {0}")]
38    Other(String),
39}