use std::error::Error as StdError;
use std::fmt::{self, Display, Formatter};
use std::io;
#[derive(Debug, Clone, PartialEq)]
pub struct BlockError {
reason: &'static str,
}
impl BlockError {
#[inline(always)]
pub(super) fn new(reason: &'static str) -> Self {
Self { reason }
}
}
impl Display for BlockError {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.write_str(self.reason)
}
}
impl StdError for BlockError {}
impl From<BlockError> for io::Error {
fn from(err: BlockError) -> io::Error {
io::Error::new(io::ErrorKind::Other, err)
}
}