summary refs log tree commit diff
path: root/src/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs33
1 files changed, 11 insertions, 22 deletions
diff --git a/src/error.rs b/src/error.rs
index b8289f6..1d291ed 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -1,5 +1,7 @@
+#![forbid(unsafe_code)]
+
 use crate::path::GenericPath;
-use crate::path::error::{FileNameError, DirectoryNameError};
+use crate::path::error::{FileNameError, DirectoryNameError, PathError};
 use crate::terminal::error::TerminalError;
 
 
@@ -12,10 +14,7 @@ pub enum Error {
   Parse(String),
   FileName(FileNameError),
   DirectoryName(DirectoryNameError),
-  PathListHasEmptyComponents(String),
-  PathLexicallyDirectory(GenericPath),
-  PathLexicallyRelative(GenericPath),
-  PathLexicallyInvalid(GenericPath),
+  Path(PathError),
   PathEmpiricallyFile(GenericPath),
   Terminal(TerminalError),
 }
@@ -29,23 +28,7 @@ impl std::fmt::Display for Error {
       Error::Parse(e) => e.fmt(f),
       Error::FileName(e) => e.fmt(f),
       Error::DirectoryName(e) => e.fmt(f),
-      Error::PathListHasEmptyComponents(path_list) =>
-        f.write_fmt(format_args!(
-            "Path list has empty components: {}",
-            path_list)),
-      Error::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)),
-      Error::PathLexicallyRelative(path) =>
-        f.write_fmt(format_args!(
-            "The path {} is relative, not absolute.",
-            path)),
-      Error::PathLexicallyInvalid(path) =>
-        f.write_fmt(format_args!(
-            "This isn't a valid path. {}",
-            path)),
+      Error::Path(e) => e.fmt(f),
       Error::PathEmpiricallyFile(path) =>
         f.write_fmt(format_args!(
             "There's a file at {}, not a directory.",
@@ -85,6 +68,12 @@ impl From<DirectoryNameError> for Error {
   }
 }
 
+impl From<PathError> for Error {
+  fn from(e: PathError) -> Error {
+    Error::Path(e)
+  }
+}
+
 impl From<TerminalError> for Error {
   fn from(e: TerminalError) -> Error {
     Error::Terminal(e)