summary refs log tree commit diff
path: root/src/path/error.rs
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@gmail.com>2020-12-29 01:25:30 -0800
committerIrene Knapp <ireneista@gmail.com>2020-12-29 01:25:30 -0800
commit3378c0c3704e1b85f23459fc1273186ec9ecbd8a (patch)
treef5a5f57c48ddfe43a1a3371e7e96dc7aa07af445 /src/path/error.rs
parentdb31e770be89cc3e693ffef470878267efeff406 (diff)
add a FromStr instance for GenericPathComponent, and a new type PathError
Diffstat (limited to 'src/path/error.rs')
-rw-r--r--src/path/error.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/path/error.rs b/src/path/error.rs
index 1162a3b..0ee5423 100644
--- a/src/path/error.rs
+++ b/src/path/error.rs
@@ -8,11 +8,18 @@ pub enum DirectoryNameError {
   ContainsSlash(String),
 }
 
+#[derive(Clone,Debug,Eq,Hash,Ord,PartialEq,PartialOrd)]
+pub enum PathError {
+  Parse(String),
+}
+
 
 impl std::error::Error for FileNameError { }
 
 impl std::error::Error for DirectoryNameError { }
 
+impl std::error::Error for PathError { }
+
 impl std::fmt::Display for FileNameError {
   fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
     match self {
@@ -33,3 +40,12 @@ impl std::fmt::Display for DirectoryNameError {
   }
 }
 
+impl std::fmt::Display for PathError {
+  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+    match self {
+      PathError::Parse(s) =>
+        f.write_fmt(format_args!("Syntax error in path: {}", s)),
+    }
+  }
+}
+