1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use serde_json::Error as JsonError;
use std::io::Error as IOError;

/// Common error type.
#[derive(thiserror::Error, Debug)]
pub enum Error {
    /// Missing environment variable.
    #[error("missing environment variable: {0}")]
    MissingEnvVar(&'static str),
    /// I/O error.
    #[error("IO Error")]
    IO(#[from] IOError),
    /// JSON error.
    #[error("Json Error")]
    Json(#[from] JsonError),
    /// Bad configuration.
    #[error("bad configuration: {0}")]
    BadConfig(String),
}

/// Type alias for Results which may return [`Error`].
pub type Result<T> = std::result::Result<T, Error>;