simple_database/
error.rs

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
#[derive(thiserror::Error, Debug)]
pub enum Error {
    #[error(transparent)]
    SerdeJson(#[from] serde_json::Error),

    #[cfg(feature = "rusqlite")]
    #[error(transparent)]
    HexError(#[from] hex::FromHexError),

    #[cfg(feature = "rusqlite")]
    #[error(transparent)]
    Rusqlite(#[from] rusqlite::Error),

    #[cfg(feature = "rusqlite")]
    #[error(transparent)]
    IoError(#[from] std::io::Error),


    #[error("Generic Error {0}: {1}")]
    Generic(String, String),
}

impl Error {
    pub fn err(ctx: &str, err: &str) -> Self {Error::Generic(ctx.to_string(), err.to_string())}
}