summaryrefslogtreecommitdiffstats
path: root/src/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs30
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)
+ }
+}