use std::error;
use std::fmt;
#[derive(Clone, Debug)]
pub struct Error {
kind: ErrorKind,
}
impl Error {
pub(crate) fn new(kind: ErrorKind) -> Error {
Error { kind }
}
pub(crate) fn unknown() -> Error {
Error::new(ErrorKind::Unknown)
}
pub fn kind(&self) -> &ErrorKind {
&self.kind
}
}
#[derive(Clone, Debug)]
pub enum ErrorKind {
Unknown,
#[doc(hidden)]
__Nonexhaustive,
}
impl error::Error for Error {
fn description(&self) -> &str {
match self.kind {
ErrorKind::Unknown => "Unknown error.",
ErrorKind::__Nonexhaustive => unreachable!(),
}
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.kind {
ErrorKind::Unknown => write!(f, "Unknown error."),
ErrorKind::__Nonexhaustive => unreachable!(),
}
}
}