From 162e1c125963c5a92ebd653e6b401aec37a629ed Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20M=2E=20Bezerra?= Date: Wed, 10 Nov 2021 20:24:57 -0300 Subject: [PATCH] Fix error message panic when cannot list non-archive files --- src/commands.rs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index 4ac4792..1559ec9 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -227,17 +227,12 @@ pub fn run(args: Opts, question_policy: QuestionPolicy) -> crate::Result<()> { .map(|(path, _)| path.clone()) .collect(); - // Error if !not_archives.is_empty() { - eprintln!("Some file you asked ouch to list the contents of is not an archive."); - for file in ¬_archives { - eprintln!("Could not list {}.", to_utf(file)); - } - todo!( - "Dev note: add this error variant and pass the Vec to it, all the files \ - lacking extension shall be shown: {:#?}.", - not_archives - ); + let error = FinalError::with_title("Cannot list archive contents") + .detail("Only archives can have their contents listed") + .detail(format!("Files are not archives: {}", concatenate_os_str_list(¬_archives))); + + return Err(error.into()); } let list_options = ListOptions { tree }; @@ -330,7 +325,6 @@ fn decompress_file( file_name: &Path, question_policy: QuestionPolicy, ) -> crate::Result<()> { - // TODO: improve error message let reader = fs::File::open(&input_file_path)?; // Output path is used by single file formats @@ -426,7 +420,6 @@ fn list_archive_contents( formats: Vec, list_options: ListOptions, ) -> crate::Result<()> { - // TODO: improve error message let reader = fs::File::open(&archive_path)?; // Zip archives are special, because they require io::Seek, so it requires it's logic separated -- 2.11.4.GIT