feat: add compression not supported as enum error#774
feat: add compression not supported as enum error#774Its-Just-Nans wants to merge 4 commits intomasterfrom
compression not supported as enum error#774Conversation
compression not supported as enum error
There was a problem hiding this comment.
This PR correctly adds a dedicated CompressionMethodNotSupported error variant to improve type safety and error handling. The implementation is complete with all necessary match arms updated and proper error message mapping. The changes follow the Conventional Commits standard and align with the issue requirements.
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
There was a problem hiding this comment.
Code Review
This pull request introduces a specific CompressionMethodNotSupported variant to the ZipError enum, replacing generic UnsupportedArchive errors across the codebase. The review feedback recommends enhancing this new error variant by including the specific compression method ID as a field. This change would provide better diagnostic context to users and requires corresponding updates to the Display, Error, and io::Error conversion implementations to handle the new variant signature.
src/read/readers.rs
Outdated
| if let CompressionMethod::Unsupported(_) = data.compression_method { | ||
| return Err(ZipError::UnsupportedArchive( | ||
| "Compression method not supported", | ||
| )); | ||
| return Err(ZipError::CompressionMethodNotSupported); |
There was a problem hiding this comment.
Capture the unsupported compression method ID and pass it to the error variant for better diagnostics.
| if let CompressionMethod::Unsupported(_) = data.compression_method { | |
| return Err(ZipError::UnsupportedArchive( | |
| "Compression method not supported", | |
| )); | |
| return Err(ZipError::CompressionMethodNotSupported); | |
| if let CompressionMethod::Unsupported(id) = data.compression_method { | |
| return Err(ZipError::CompressionMethodNotSupported(id)); |
References
- When changing the type of a field, ensure all implementations that use this field are updated accordingly to avoid compilation errors.
src/result.rs
Outdated
| InvalidPassword, | ||
|
|
||
| /// Compression method not supported | ||
| CompressionMethodNotSupported, |
There was a problem hiding this comment.
Can you also expose the compression method used? Ideally in a way that we can both Display and read the compression number from. Otherwise we can't give the full information to the user.
fix #773