diff options
author | Qrius <[email protected]> | 2024-09-26 00:11:05 +0200 |
---|---|---|
committer | Qrius <[email protected]> | 2024-09-26 00:11:05 +0200 |
commit | e6ab276a4d5daaf0dd40eed5e2ff477b48187f77 (patch) | |
tree | d9394d87b428d15e45706b7f3de0eda4cbddeb0e /src/macro_processor/error.rs | |
parent | e489f7d9f8b799ee1605b4d5cb65fe7adf24ea22 (diff) | |
download | skaldpress-e6ab276a4d5daaf0dd40eed5e2ff477b48187f77.tar.gz skaldpress-e6ab276a4d5daaf0dd40eed5e2ff477b48187f77.zip |
Change return of MacroProcessor to Result
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 {} |