diff options
Diffstat (limited to 'src/macro_processor/error.rs')
-rw-r--r-- | src/macro_processor/error.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/macro_processor/error.rs b/src/macro_processor/error.rs new file mode 100644 index 0000000..074a8ef --- /dev/null +++ b/src/macro_processor/error.rs @@ -0,0 +1,23 @@ +use std::error::Error; +use std::fmt; + +#[derive(Debug)] +pub enum SMPError { + IncludeError(u8, std::io::Error, String), + ShellCommandError(u8, Box<dyn Error>), +} + +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) + } + } + } +} + +impl std::error::Error for SMPError {} |