use std::fmt::{self, Display};
#[derive(Debug)]
pub struct Error {
message: String,
}
pub type Result<T> = std::result::Result<T, Error>;
impl Error {
pub fn new<T: Display>(message: T) -> Self {
Error {
message: message.to_string(),
}
}
}
impl std::error::Error for Error {}
impl Display for Error {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str(&self.message)
}
}
#[doc(hidden)]
#[allow(non_snake_case)]
pub fn Error<T: Display>(message: T) -> Error {
Error::new(message)
}