mirror of https://github.com/getmango/Mango.git
Add error handling on `read_page` (fixes #281)
This commit is contained in:
parent
6ab885499c
commit
8814778c22
|
@ -144,13 +144,17 @@ class Entry
|
||||||
def read_page(page_num)
|
def read_page(page_num)
|
||||||
raise "Unreadble archive. #{@err_msg}" if @err_msg
|
raise "Unreadble archive. #{@err_msg}" if @err_msg
|
||||||
img = nil
|
img = nil
|
||||||
sorted_archive_entries do |file, entries|
|
begin
|
||||||
page = entries[page_num - 1]
|
sorted_archive_entries do |file, entries|
|
||||||
data = file.read_entry page
|
page = entries[page_num - 1]
|
||||||
if data
|
data = file.read_entry page
|
||||||
img = Image.new data, MIME.from_filename(page.filename), page.filename,
|
if data
|
||||||
data.size
|
img = Image.new data, MIME.from_filename(page.filename),
|
||||||
|
page.filename, data.size
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
rescue e
|
||||||
|
Logger.warn "Unable to read page #{page_num} of #{@zip_path}. Error: #{e}"
|
||||||
end
|
end
|
||||||
img
|
img
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue