1use std::error::Error as StdError;
2use std::fmt::{self, Display, Formatter};
3use std::io;
4
5#[derive(Debug, Clone, PartialEq)]
11pub struct BlockError {
12 reason: &'static str,
13}
14
15impl BlockError {
16 #[inline(always)]
17 pub(super) fn new(reason: &'static str) -> Self {
18 Self { reason }
19 }
20}
21
22impl Display for BlockError {
23 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
24 f.write_str(self.reason)
25 }
26}
27
28impl StdError for BlockError {}
29
30impl From<BlockError> for io::Error {
31 fn from(err: BlockError) -> io::Error {
32 io::Error::new(io::ErrorKind::Other, err)
34 }
35}