summaryrefslogtreecommitdiffstats
path: root/src/error.rs
blob: a46285bc1afc0aa15b41b418e90fa6402b64ead7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use std::process::{ExitCode, Termination};

pub type Result<T> = std::result::Result<T, Error>;

#[derive(thiserror::Error, Debug)]
#[repr(u8)]
pub enum Error {
    #[error("IO error: {0}")]
    IO(#[from] std::io::Error),

    #[error("Config error: {0}")]
    Config(#[from] figment::error::Error),

    #[error("Paths error: {0}")]
    Paths(#[from] crate::paths::Error),

    #[error("Finder error: {0}")]
    Finder(#[from] crate::finder::Error),
}

impl Termination for Error {
    fn report(self) -> ExitCode {
        eprintln!("{}", self);
        ExitCode::FAILURE
    }
}