Skip to content

Commit

Permalink
feat: Improve ErrorKind in ZipError to io::Error conversion (previously
Browse files Browse the repository at this point in the history
  • Loading branch information
Pr0methean committed Apr 30, 2024
1 parent 9739df0 commit 686f6f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ fn main() {
if var("CARGO_FEATURE_DEFLATE_MINIZ").is_ok() {
println!("cargo:warning=Feature `deflate-miniz` is deprecated; replace it with `deflate`");
}
}
}
10 changes: 9 additions & 1 deletion src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,15 @@ impl ZipError {

impl From<ZipError> for io::Error {
fn from(err: ZipError) -> io::Error {
io::Error::new(io::ErrorKind::Other, err)
let kind = match &err {
ZipError::Io(err) => err.kind(),
ZipError::InvalidArchive(_) => io::ErrorKind::InvalidData,
ZipError::UnsupportedArchive(_) => io::ErrorKind::Unsupported,
ZipError::FileNotFound => io::ErrorKind::NotFound,
ZipError::InvalidPassword => io::ErrorKind::InvalidInput,
};

io::Error::new(kind, err)
}
}

Expand Down

0 comments on commit 686f6f1

Please sign in to comment.