use std::error::Error; use std::fmt; #[derive(Debug)] pub enum SMPError { IncludeError(u8, std::io::Error, String), ShellCommandError(u8, Box), UnknownError(u8, Option>), } impl fmt::Display for SMPError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { SMPError::IncludeError(code, _, file) => { write!(f, "[SMP{}] Error reading file \"{}\"", code, file) } SMPError::ShellCommandError(code, e) => { write!(f, "[SMP{}] Error running shell command \"{:#?}\"", code, e) } SMPError::UnknownError(code, e) => { write!( f, "[SMP{}] Unknown macro processing error occurred \"{:#?}\"", code, e ) } } } } impl std::error::Error for SMPError {}