From 2fcec33ec62d03be150b96e2ca48ac9b964c11c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20M=2E=20Bezerra?= Date: Tue, 2 Nov 2021 07:36:03 -0300 Subject: [PATCH] Removing obsolete error variants --- src/error.rs | 65 +++++++--------------------------------------------- 1 file changed, 8 insertions(+), 57 deletions(-) diff --git a/src/error.rs b/src/error.rs index e51449d..81c5eef 100644 --- a/src/error.rs +++ b/src/error.rs @@ -9,49 +9,28 @@ use std::{ use crate::utils::colors::*; +#[allow(missing_docs)] /// All errors that can be generated by `ouch` #[derive(Debug, PartialEq)] pub enum Error { - /// Extension found is not supported and known to ouch - UnknownExtensionError(String), - /// TO BE REMOVED - MissingExtensionError(PathBuf), /// Not every IoError, some of them get filtered by `From` into other variants - IoError { - /// TODO - reason: String, - }, + IoError { reason: String }, /// Detected from io::Error if .kind() is io::ErrorKind::NotFound FileNotFound(PathBuf), - /// TO BE REMOVED + /// NEEDS MORE CONTEXT AlreadyExists, - /// TO BE REMOVED + /// From zip::result::ZipError::InvalidArchive InvalidZipArchive(&'static str), /// Detected from io::Error if .kind() is io::ErrorKind::PermissionDenied - PermissionDenied { - /// TODO - error_title: String, - }, - /// TO BE REMOVED + PermissionDenied { error_title: String }, + /// From zip::result::ZipError::UnsupportedArchive UnsupportedZipArchive(&'static str), /// TO BE REMOVED CompressingRootFolder, - /// TO BE REMOVED - MissingArgumentsForCompression, - /// TO BE REMOVED - MissingArgumentsForDecompression, - /// TO BE REMOVED - CompressionTypo, /// Specialized walkdir's io::Error wrapper with additional information on the error - WalkdirError { - /// TODO - reason: String, - }, + WalkdirError { reason: String }, /// Custom and unique errors are reported in this variant - Custom { - /// TODO - reason: FinalError, - }, + Custom { reason: FinalError }, } /// Alias to std's Result with ouch's Error @@ -113,12 +92,6 @@ impl FinalError { impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let err = match self { - Error::MissingExtensionError(filename) => { - FinalError::with_title(format!("Cannot compress to {:?}", filename)) - .detail("Ouch could not detect the compression format") - .hint("Use a supported format extension, like '.zip' or '.tar.gz'") - .hint("Check https://github.com/ouch-org/ouch for a full list of supported formats") - } Error::WalkdirError { reason } => FinalError::with_title(reason), Error::FileNotFound(file) => { if file == Path::new("") { @@ -132,29 +105,7 @@ impl fmt::Display for Error { .detail("This is unadvisable since ouch does compressions in-memory.") .hint("Use a more appropriate tool for this, such as rsync.") } - Error::MissingArgumentsForCompression => { - FinalError::with_title("Could not compress") - .detail("The compress command requires at least 2 arguments") - .hint("You must provide:") - .hint(" - At least one input argument.") - .hint(" - The output argument.") - .hint("") - .hint("Example: `ouch compress image.png img.zip`") - } - Error::MissingArgumentsForDecompression => { - FinalError::with_title("Could not decompress") - .detail("The compress command requires at least one argument") - .hint("You must provide:") - .hint(" - At least one input argument.") - .hint("") - .hint("Example: `ouch decompress imgs.tar.gz`") - } Error::IoError { reason } => FinalError::with_title(reason), - Error::CompressionTypo => { - FinalError::with_title("Possible typo detected") - .hint(format!("Did you mean '{}ouch compress{}'?", *MAGENTA, *RESET)) - } - Error::UnknownExtensionError(_) => todo!(), Error::AlreadyExists => todo!(), Error::InvalidZipArchive(_) => todo!(), Error::PermissionDenied { error_title } => FinalError::with_title(error_title).detail("Permission denied"),