#[derive(Debug)] pub struct Error { pub message: String, } impl std::fmt::Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{}", self.message) } } impl std::error::Error for Error {} impl Error { // has to be Box to fit with the result in prelude.rs pub fn new(message: &str) -> Box { Box::new(Self { message: message.to_string(), }) } }