summary refs log tree commit diff
path: root/src/path
diff options
context:
space:
mode:
Diffstat (limited to 'src/path')
-rw-r--r--src/path/error.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/path/error.rs b/src/path/error.rs
new file mode 100644
index 0000000..1162a3b
--- /dev/null
+++ b/src/path/error.rs
@@ -0,0 +1,35 @@
+#[derive(Clone,Debug,Eq,Hash,Ord,PartialEq,PartialOrd)]
+pub enum FileNameError {
+  ContainsSlash(String),
+}
+
+#[derive(Clone,Debug,Eq,Hash,Ord,PartialEq,PartialOrd)]
+pub enum DirectoryNameError {
+  ContainsSlash(String),
+}
+
+
+impl std::error::Error for FileNameError { }
+
+impl std::error::Error for DirectoryNameError { }
+
+impl std::fmt::Display for FileNameError {
+  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+    match self {
+      FileNameError::ContainsSlash(s) =>
+        f.write_fmt(format_args!(
+            "File names cannot contain slashes, but {:?} does.", s)),
+    }
+  }
+}
+
+impl std::fmt::Display for DirectoryNameError {
+  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+    match self {
+      DirectoryNameError::ContainsSlash(s) =>
+        f.write_fmt(format_args!(
+            "File names cannot contain slashes, but {:?} does.", s)),
+    }
+  }
+}
+