From bc3bd146bbcafd267f6a0a59faade943bb2ad6fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20du=20Garreau?= Date: Fri, 22 Dec 2023 12:18:05 +0100 Subject: [PATCH] Improve `ErrorKind` in `ZipError` to `io::Error` conversion --- src/result.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/result.rs b/src/result.rs index 00d558cb4..0f295436a 100644 --- a/src/result.rs +++ b/src/result.rs @@ -78,7 +78,14 @@ impl ZipError { impl From 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) } }