Improve zip errors when paths are not utf8 valid#181
Conversation
And refactor function implementations
if !invalid_unicode_filenames.is_empty() {
let error = FinalError::with_title("Cannot build zip archive")
.detail("Zip archives require files to have valid UTF-8 paths")
.detail(format!("Files with invalid paths: {}", concatenate_os_str_list(&invalid_unicode_filenames)));
return Err(error.into());
}@GabrielSimonetto this is an error produced inside of the archive logic, but we don't have the name of the path that is being outputted, I just had an new idea! What if we grab the Result<_, Error> and call a function on it before propagating up. What this function would do: check if it is Error::Custom, and add a .detail() line to it, then returning with This idea is meant to solve #131. |
|
Hmm, but I feel like we need to go back to the caller to know which was the output_path, but you said:
How will a function inside this context be able to grab the output_path? |
Would be done with a function outside. Inside of the if !invalid_unicode_filenames.is_empty() {
let error = FinalError::with_title("Cannot build zip archive")
.detail("Zip archives require files to have valid UTF-8 paths")
.detail(format!("Files with invalid paths: {}", concatenate_os_str_list(&invalid_unicode_filenames)));
return Err(error.into());
}Outside currently: archive::zip::build_archive_from_paths(&files, &mut vec_buffer)?;But could be like: archive::zip::build_archive_from_paths(&files, &mut vec_buffer)
.map_err(|err| add_detail(err, format!("Occurred in {}", output_path.display())))?; |
|
But I'm convinced that we don't really need this for compression, because there will always just be one compression output file. But for extracting, we need to say the name. |
No description provided.