use snafu::prelude::*;

#[derive(Debug, Snafu)]
#[snafu(visibility(pub(crate)))]
pub enum Error {
    #[snafu(display("arti-client error"))]
    ArtiClient { source: arti_client::Error },

    #[snafu(display("invalid hidden service nickname"))]
    InvalidNickname {
        source: tor_hsservice::InvalidNickname,
    },

    #[snafu(display("error building tor config"))]
    ConfigBuild {
        source: arti_client::config::ConfigBuildError,
    },

    #[snafu(display("empty onion service, unable to initialize {name}"))]
    EmptyOnionService { name: String },

    #[snafu(display("tor client error"))]
    Client {
        source: Box<tor_hsservice::ClientError>,
    },

    #[snafu(display("tor programmer error"))]
    ArtiBug { source: tor_error::Bug },

    #[snafu(display("I/O error"))]
    Io { source: std::io::Error },

    #[cfg(feature = "http-client")]
    #[snafu(display("rustls error"))]
    Rustls { source: rustls::Error },

    #[cfg(feature = "http-client")]
    #[snafu(display("hyper error"))]
    Hyper { source: hyper::Error },

    #[cfg(feature = "http-client")]
    #[snafu(display("hyper http error"))]
    HyperHttp { source: hyper::http::Error },
}
