use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum Error {
#[error("{host}: network: {message}")]
Network { host: String, message: String },
#[error("{host}: rejected: {message}")]
Rejected { host: String, message: String },
#[error("{host}: auth: {message}")]
Auth { host: String, message: String },
#[error("{host}: parse: {message}")]
Parse { host: String, message: String },
#[error("{host}: unsupported: {message}")]
Unsupported { host: String, message: String },
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn network_error_message_contains_host() {
let err = Error::Network {
host: "192.0.2.1".to_string(),
message: "connection refused".to_string(),
};
assert!(err.to_string().contains("192.0.2.1"));
}
}