Add error handling on `read_page` (fixes #281)

This commit is contained in:
Alex Ling 2022-03-12 14:18:08 +00:00
parent 6ab885499c
commit 8814778c22
1 changed files with 10 additions and 6 deletions

View File

@ -144,14 +144,18 @@ class Entry
def read_page(page_num)
raise "Unreadble archive. #{@err_msg}" if @err_msg
img = nil
begin
sorted_archive_entries do |file, entries|
page = entries[page_num - 1]
data = file.read_entry page
if data
img = Image.new data, MIME.from_filename(page.filename), page.filename,
data.size
img = Image.new data, MIME.from_filename(page.filename),
page.filename, data.size
end
end
rescue e
Logger.warn "Unable to read page #{page_num} of #{@zip_path}. Error: #{e}"
end
img
end