summary refs log tree commit diff
path: root/src/path/error.rs
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@gmail.com>2021-03-11 20:15:47 -0800
committerIrene Knapp <ireneista@gmail.com>2021-03-11 20:15:47 -0800
commit86990efcf8fa63decb05f462d745b95e4992dc77 (patch)
tree46990fd1c749ccca0b6477650973d83174e5e264 /src/path/error.rs
parenta159d4dd29491a1eb88163e63ceb41a903dc47b6 (diff)
refactor everything into smaller modules; move to using async-std; make the read loop async. some stuff doesn't work yet but it needed to be done and this is as clean a state as it's likely to get in, so we're committing it as a base to build on.
Diffstat (limited to 'src/path/error.rs')
-rw-r--r--src/path/error.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/path/error.rs b/src/path/error.rs
index 0ee5423..aee6e9f 100644
--- a/src/path/error.rs
+++ b/src/path/error.rs
@@ -1,3 +1,10 @@
+#![forbid(unsafe_code)]
+
+use crate::path::GenericPath;
+
+pub type Result<T> = std::result::Result<T, PathError>;
+
+
 #[derive(Clone,Debug,Eq,Hash,Ord,PartialEq,PartialOrd)]
 pub enum FileNameError {
   ContainsSlash(String),
@@ -11,6 +18,10 @@ pub enum DirectoryNameError {
 #[derive(Clone,Debug,Eq,Hash,Ord,PartialEq,PartialOrd)]
 pub enum PathError {
   Parse(String),
+  PathLexicallyDirectory(GenericPath),
+  PathLexicallyRelative(GenericPath),
+  PathLexicallyInvalid(GenericPath),
+  PathListHasEmptyComponents(String),
 }
 
 
@@ -45,6 +56,23 @@ impl std::fmt::Display for PathError {
     match self {
       PathError::Parse(s) =>
         f.write_fmt(format_args!("Syntax error in path: {}", s)),
+      PathError::PathLexicallyDirectory(path) =>
+        f.write_fmt(format_args!(
+            "The path {} ends in a slash, but is supposed to refer to a file, \
+             not a directory.",
+            path)),
+      PathError::PathLexicallyRelative(path) =>
+        f.write_fmt(format_args!(
+            "The path {} is relative, not absolute.",
+            path)),
+      PathError::PathLexicallyInvalid(path) =>
+        f.write_fmt(format_args!(
+            "This isn't a valid path. {}",
+            path)),
+      PathError::PathListHasEmptyComponents(path_list) =>
+        f.write_fmt(format_args!(
+            "Path list has empty components: {}",
+            path_list)),
     }
   }
 }