Skip to main content

finance_core/
error.rs

1// ═══════════════════════════════════════════════════════════════════════════
2// CoreError — errors surfaced by shared accounting-suite primitives.
3//
4// Consumer CLIs (invoice-cli, receipt-cli, …) typically define their own
5// AppError with a `#[from] CoreError` variant so they can wrap and extend it.
6// ═══════════════════════════════════════════════════════════════════════════
7
8use thiserror::Error;
9
10#[derive(Error, Debug)]
11pub enum CoreError {
12    #[error("config error: {0}")]
13    Config(String),
14
15    #[error("path resolution failed: {0}")]
16    Path(String),
17
18    #[error("io error: {0}")]
19    Io(#[from] std::io::Error),
20
21    #[error("database error: {0}")]
22    Db(#[from] rusqlite::Error),
23
24    #[error("migration error: {0}")]
25    Migration(#[from] refinery::Error),
26
27    #[error("serialization error: {0}")]
28    Toml(#[from] toml::de::Error),
29
30    #[error("serialization error: {0}")]
31    TomlSer(#[from] toml::ser::Error),
32}
33
34pub type Result<T> = std::result::Result<T, CoreError>;