#[derive(Debug)]
pub struct Error {
pub message: String,
}
impl Error {
pub fn new(message: &str) -> Self {
Self {
message: message.to_string(),
}
}
}
impl std::error::Error for Error {
fn description(&self) -> &str {
&self.message
}
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", self.message)
}
}
impl From<std::io::Error> for Error {
fn from(error: std::io::Error) -> Error {
Error {
message: error.to_string(),
}
}
}
impl From<std::string::FromUtf8Error> for Error {
fn from(error: std::string::FromUtf8Error) -> Error {
Error {
message: error.to_string(),
}
}
}
impl From<regex::Error> for Error {
fn from(error: regex::Error) -> Error {
Error {
message: error.to_string(),
}
}
}
impl From<nix::errno::Errno> for Error {
fn from(error: nix::errno::Errno) -> Error {
Error {
message: error.to_string(),
}
}
}