use std::error;
use std::fmt;
use std::io;
#[derive(Debug)]
pub enum ProbeError {
IO(io::Error, String),
UnexpectedContent(String),
InvalidInput(String),
StatusFailure(String),
}
impl fmt::Display for ProbeError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
ProbeError::IO(ref err, ref path) => write!(f, "{} for {}", err, path),
ProbeError::UnexpectedContent(ref err) => write!(f, "{}", err),
ProbeError::InvalidInput(ref err) => write!(f, "{}", err),
ProbeError::StatusFailure(ref err) => write!(f, "{}", err),
}
}
}
impl error::Error for ProbeError {
fn description(&self) -> &str {
match *self {
#[allow(deprecated)]
ProbeError::IO(ref err, ref _path) => err.description(),
ProbeError::UnexpectedContent(ref err) => err,
ProbeError::InvalidInput(ref err) => err,
ProbeError::StatusFailure(ref err) => err,
}
}
fn cause(&self) -> Option<&dyn error::Error> {
match *self {
ProbeError::IO(ref err, ref _path) => Some(err),
ProbeError::UnexpectedContent(_) => None,
ProbeError::InvalidInput(_) => None,
ProbeError::StatusFailure(_) => None,
}
}
}