Skip to content

Commit

Permalink
Add error handling on read_page (fixes #281)
Browse files Browse the repository at this point in the history
  • Loading branch information
hkalexling committed Mar 12, 2022
1 parent 6ab8854 commit 8814778
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/library/entry.cr
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,17 @@ class Entry
def read_page(page_num)
raise "Unreadble archive. #{@err_msg}" if @err_msg
img = nil
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
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
end
end
rescue e
Logger.warn "Unable to read page #{page_num} of #{@zip_path}. Error: #{e}"
end
img
end
Expand Down

0 comments on commit 8814778

Please sign in to comment.