improve fatal error message

This commit is contained in:
João M. Bezerra 2022-10-15 22:06:40 -03:00
parent 2da497c1ca
commit 70bdfc4e99

View File

@ -182,13 +182,19 @@ pub fn run(
// about whether the command succeeded without such a message
info!(accessible, "Successfully compressed '{}'.", to_utf(&output_path));
} else {
// If Ok(false) or Err() occurred, delete incomplete file at `output_path`
//
// if deleting fails, print an extra alert message pointing
// out that we left a possibly CORRUPTED file at `output_path`
if let Err(_) = utils::remove_file_or_dir(&output_path) {
eprintln!("{red}FATAL ERROR:\n", red = *colors::RED);
eprintln!(" Please manually delete '{}'.", to_utf(&output_path));
eprintln!(
" Compression failed and we could not delete '{}'.",
to_utf(&output_path),
);
eprintln!(" Ouch failed to delete the file '{}'.", to_utf(&output_path));
eprintln!(" Please delete it manually.");
eprintln!(" This file is corrupted if compression didn't finished.");
if let Err(_) = compress_result {
eprintln!(" Compression failed for reasons below.");
}
}
}