From 5c0847bc9b67a8f7c4b35bd6de69eff0ad969f98 Mon Sep 17 00:00:00 2001 From: Bjorn Harpe Date: Tue, 4 Feb 2020 09:17:12 -0700 Subject: [PATCH] Add detailed exception - if the return from `archive_read_data_block` is an error ( less than 0 ), look up the reported error string and raise an archive exception with the error string --- libarchive/adapters/archive_read.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libarchive/adapters/archive_read.py b/libarchive/adapters/archive_read.py index a299104..13c6eb5 100644 --- a/libarchive/adapters/archive_read.py +++ b/libarchive/adapters/archive_read.py @@ -209,6 +209,9 @@ def _read_by_block(archive_res): elif r == libarchive.constants.archive.ARCHIVE_EOF: break + elif r < 0: + message = c_archive_error_string(archive_res) + raise libarchive.exception.ArchiveError(message) else: raise ValueError("Read failed (archive_read_data_block): (%d)" % (r,))