summary refs log tree commit diff
path: root/src/path
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@gmail.com>2020-12-28 16:29:24 -0800
committerIrene Knapp <ireneista@gmail.com>2020-12-28 16:29:24 -0800
commitdb31e770be89cc3e693ffef470878267efeff406 (patch)
treef09c7dab9d2b9db0a09650d071b6577e001e5b98 /src/path
parentbcd2e282af2b6cd7991d8d1c5ebef4e4e4a1c745 (diff)
the which builtin now sorta works. yay!
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)),
+    }
+  }
+}
+