1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
use std::fmt::{Formatter, Result};
use std::io;

#[derive(Debug)]
pub enum Error {
    Logic(String),
    IOError(io::Error),
    Other(Box<dyn std::error::Error>),
}

impl std::fmt::Display for Error {
    fn fmt(&self, f: &mut Formatter<'_>) -> Result {
        match self {
            Error::Logic(msg) => write!(f, "logic error:{}", msg),
            Error::IOError(err) => write!(f, "io error:{}", err),
            Error::Other(err) => write!(f, "{}", err),
        }
    }
}

impl std::error::Error for Error {}