use std::fmt;
use std::io;
pub type Result<T> = std::result::Result<T, NessusError>;
#[derive(Debug)]
pub enum NessusError {
Http(reqwest::Error),
Json(serde_json::Error),
Config(String),
Io(io::Error),
Other(String),
}
impl fmt::Display for NessusError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
NessusError::Http(e) => write!(f, "HTTP error: {e}"),
NessusError::Json(e) => write!(f, "JSON error: {e}"),
NessusError::Config(msg) => write!(f, "Configuration error: {msg}"),
NessusError::Io(e) => write!(f, "I/O error: {e}"),
NessusError::Other(msg) => write!(f, "Error: {msg}"),
}
}
}
impl std::error::Error for NessusError {}
impl From<reqwest::Error> for NessusError {
fn from(e: reqwest::Error) -> Self {
NessusError::Http(e)
}
}
impl From<serde_json::Error> for NessusError {
fn from(e: serde_json::Error) -> Self {
NessusError::Json(e)
}
}
impl From<io::Error> for NessusError {
fn from(e: io::Error) -> Self {
NessusError::Io(e)
}
}