-
Notifications
You must be signed in to change notification settings - Fork 105
Closed
Description
I am seeing that we have a custom error in case someone wrongly types a desired extension:
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")
}
But it seems that this is not being called anymore, since we get a different error when testing ouch
$ ouch c input_abacaxi.txt output_abacaxi.txt refined_abacaxi.txt el_strong.zip.missigno
[ERROR] Cannot compress to 'el_strong.zip.missigno'.
- You shall supply the compression format via the extension.
hint: Try adding something like .tar.gz or .zip to the output file.
hint:
hint: Examples:
hint: ouch compress ... el_strong.zip.missigno.tar.gz
hint: ouch compress ... el_strong.zip.missigno.zip
And this message is defined in commands.rs
, where it is defined using FinalError
if formats.is_empty() {
let reason = FinalError::with_title(format!("Cannot compress to '{}'.", to_utf(&output_path)))
.detail("You shall supply the compression format via the extension.")
.hint("Try adding something like .tar.gz or .zip to the output file.")
.hint("")
.hint("Examples:")
.hint(format!(" ouch compress ... {}.tar.gz", to_utf(&output_path)))
.hint(format!(" ouch compress ... {}.zip", to_utf(&output_path)));
return Err(Error::with_reason(reason));
}
I don't believe it's just a matter of calling the different MissingExtensionError
instead of FinalError
, since we don't know at this point if the reason why formats came back empty was because of an inexistent extension, so we need to propagate it from inside the formats constructor operation.
Metadata
Metadata
Assignees
Labels
No labels