-
Notifications
You must be signed in to change notification settings - Fork 106
feat: add compression not supported as enum error
#774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -229,9 +229,7 @@ pub(crate) fn make_crypto_reader<'a, R: Read + ?Sized>( | |||||||||||||||
| #[allow(deprecated)] | ||||||||||||||||
| { | ||||||||||||||||
| if let CompressionMethod::Unsupported(_) = data.compression_method { | ||||||||||||||||
| return Err(ZipError::UnsupportedArchive( | ||||||||||||||||
| "Compression method not supported", | ||||||||||||||||
| )); | ||||||||||||||||
| return Err(ZipError::CompressionMethodNotSupported); | ||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Capture the unsupported compression method ID and pass it to the error variant for better diagnostics.
Suggested change
References
|
||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,9 @@ pub enum ZipError { | |
|
|
||
| /// provided password is incorrect | ||
| InvalidPassword, | ||
|
|
||
| /// Compression method not supported | ||
| CompressionMethodNotSupported, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also expose the compression method used? Ideally in a way that we can both
Its-Just-Nans marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| impl ZipError { | ||
|
|
@@ -52,6 +55,7 @@ impl Display for ZipError { | |
| Self::UnsupportedArchive(e) => write!(f, "unsupported Zip archive: {e}"), | ||
| Self::FileNotFound => f.write_str("specified file not found in archive"), | ||
| Self::InvalidPassword => f.write_str("provided password is incorrect"), | ||
| Self::CompressionMethodNotSupported => f.write_str("compression method not supported"), | ||
|
Its-Just-Nans marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
| } | ||
|
|
@@ -63,7 +67,8 @@ impl Error for ZipError { | |
| Self::InvalidArchive(_) | ||
| | Self::UnsupportedArchive(_) | ||
| | Self::FileNotFound | ||
| | Self::InvalidPassword => None, | ||
| | Self::InvalidPassword | ||
| | Self::CompressionMethodNotSupported => None, | ||
|
Its-Just-Nans marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
| } | ||
|
|
@@ -73,7 +78,9 @@ impl From<ZipError> for io::Error { | |
| let kind = match &err { | ||
| ZipError::Io(err) => err.kind(), | ||
| ZipError::InvalidArchive(_) => io::ErrorKind::InvalidData, | ||
| ZipError::UnsupportedArchive(_) => io::ErrorKind::Unsupported, | ||
| ZipError::UnsupportedArchive(_) | ZipError::CompressionMethodNotSupported => { | ||
| io::ErrorKind::Unsupported | ||
| } | ||
|
Its-Just-Nans marked this conversation as resolved.
Outdated
|
||
| ZipError::FileNotFound => io::ErrorKind::NotFound, | ||
| ZipError::InvalidPassword => io::ErrorKind::InvalidInput, | ||
| }; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.