diff options
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/src/error.rs b/src/error.rs index adb19bc..8e51880 100644 --- a/src/error.rs +++ b/src/error.rs @@ -2,54 +2,54 @@ use crate::path::GenericPath; type ParseError<'a> = - lalrpop_util::ParseError<usize, lalrpop_util::lexer::Token<'a>, &'a str>; + lalrpop_util::ParseError<usize, lalrpop_util::lexer::Token<'a>, &'a str>; #[derive(Debug)] pub enum Error { - IO(std::io::Error), - Parse(String), - PathListHasEmptyComponents(String), - PathIsAFile(GenericPath), - PathIsRelative(GenericPath), - PathInvalid(GenericPath), + IO(std::io::Error), + Parse(String), + PathListHasEmptyComponents(String), + PathIsAFile(GenericPath), + PathIsRelative(GenericPath), + PathInvalid(GenericPath), } impl std::error::Error for Error { } impl std::fmt::Display for Error { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Error::IO(e) => e.fmt(f), - Error::Parse(e) => e.fmt(f), - Error::PathListHasEmptyComponents(path_list) => - f.write_fmt(format_args!( - "Path list has empty components: {}", - path_list)), - Error::PathIsAFile(path) => - f.write_fmt(format_args!( - "There's a file at {}, not a directory.", - path)), - Error::PathIsRelative(path) => - f.write_fmt(format_args!( - "The path {} is relative, not absolute.", - path)), - Error::PathInvalid(path) => - f.write_fmt(format_args!( - "This isn't a valid path. {}", - path)), - } + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Error::IO(e) => e.fmt(f), + Error::Parse(e) => e.fmt(f), + Error::PathListHasEmptyComponents(path_list) => + f.write_fmt(format_args!( + "Path list has empty components: {}", + path_list)), + Error::PathIsAFile(path) => + f.write_fmt(format_args!( + "There's a file at {}, not a directory.", + path)), + Error::PathIsRelative(path) => + f.write_fmt(format_args!( + "The path {} is relative, not absolute.", + path)), + Error::PathInvalid(path) => + f.write_fmt(format_args!( + "This isn't a valid path. {}", + path)), } + } } impl From<std::io::Error> for Error { - fn from(e: std::io::Error) -> Error { - Error::IO(e) - } + fn from(e: std::io::Error) -> Error { + Error::IO(e) + } } impl From<ParseError<'_>> for Error { - fn from(e: ParseError<'_>) -> Error { - Error::Parse(format!("{}", e)) - } + fn from(e: ParseError<'_>) -> Error { + Error::Parse(format!("{}", e)) + } } |