Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

Commit

Permalink
Improve ErrorKind in ZipError to io::Error conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
a1phyr committed Dec 22, 2023
1 parent 3e88fe6 commit bc3bd14
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,14 @@ 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,
};

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

Expand Down

0 comments on commit bc3bd14

Please sign in to comment.