use std::error::Error;
use std::fmt;
use std::io;
#[derive(Debug)]
pub enum BellronosError {
IO(io::Error),
Parser(String),
Type(String),
Runtime(String),
Network(String),
Package(String),
}
impl fmt::Display for BellronosError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
BellronosError::IO(err) => write!(f, "IO error: {}", err),
BellronosError::Parser(msg) => write!(f, "Parser error: {}", msg),
BellronosError::Type(msg) => write!(f, "Type error: {}", msg),
BellronosError::Runtime(msg) => write!(f, "Runtime error: {}", msg),
BellronosError::Network(msg) => write!(f, "Network error: {}", msg),
BellronosError::Package(msg) => write!(f, "Package error: {}", msg),
}
}
}
impl Error for BellronosError {}
impl From<io::Error> for BellronosError {
fn from(err: io::Error) -> BellronosError {
BellronosError::IO(err)
}
}