diff options
author | 2024-11-13 20:00:15 +0000 | |
---|---|---|
committer | 2024-11-13 20:00:15 +0000 | |
commit | b7a2265e9b29d8fa09f84f5213ef7f8ed3045ca6 (patch) | |
tree | 280a31f5887aafdaa200a2b5f4c05ff106d9e365 /src/error.rs | |
download | critch-b7a2265e9b29d8fa09f84f5213ef7f8ed3045ca6.tar.gz critch-b7a2265e9b29d8fa09f84f5213ef7f8ed3045ca6.tar.bz2 critch-b7a2265e9b29d8fa09f84f5213ef7f8ed3045ca6.zip |
initial commit
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/error.rs b/src/error.rs new file mode 100644 index 0000000..03cad93 --- /dev/null +++ b/src/error.rs @@ -0,0 +1,30 @@ +use std::fmt::Display; + +#[derive(Debug)] +pub enum Error { + IOError(std::io::Error), + TOMLError(toml::de::Error), +} + +impl Display for Error { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Error::IOError(error) => write!(f, "IO Error: {}", error), + Error::TOMLError(error) => write!(f, "TOML deserialization error: {}", error), + } + } +} + +impl std::error::Error for Error {} + +impl From<std::io::Error> for Error { + fn from(e: std::io::Error) -> Self { + Self::IOError(e) + } +} + +impl From<toml::de::Error> for Error { + fn from(e: toml::de::Error) -> Self { + Self::TOMLError(e) + } +} |