summary refs log tree commit diff
path: root/lib/src/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/src/error.rs')
-rw-r--r--lib/src/error.rs37
1 files changed, 24 insertions, 13 deletions
diff --git a/lib/src/error.rs b/lib/src/error.rs
index cd4a760..216df78 100644
--- a/lib/src/error.rs
+++ b/lib/src/error.rs
@@ -1,30 +1,41 @@
 #[derive(Debug)]
 pub enum Error {
-    IO(std::io::Error),
+  IO(std::io::Error),
+  Parse,
 }
 
 impl std::error::Error for Error { }
 
 impl std::fmt::Display for Error {
-    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
-        match self {
-            Error::IO(e) => e.fmt(f),
-        }
+  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+    match self {
+      Error::IO(e) => e.fmt(f),
+      Error::Parse => f.write_str("Parse error"),
     }
+  }
 }
 
 impl std::cmp::PartialEq for Error {
-    fn eq(&self, other: &Self) -> bool {
-        match (self, other) {
-            (Error::IO(_), Error::IO(_)) =>
-                false,
-        }
+  fn eq(&self, other: &Self) -> bool {
+    match (self, other) {
+      (Error::IO(_), Error::IO(_)) =>
+        false,
+      (Error::Parse, Error::Parse) =>
+        true,
+      _ =>
+        false,
     }
+  }
 }
 
 impl From<std::io::Error> for Error {
-    fn from(e: std::io::Error) -> Error {
-        Error::IO(e)
-    }
+  fn from(e: std::io::Error) -> Error {
+    Error::IO(e)
+  }
 }
 
+impl From<std::num::ParseIntError> for Error {
+  fn from(_: std::num::ParseIntError) -> Error {
+    Error::Parse
+  }
+}