mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
issue error directly when doc is malformated
This should popup a message saying "No reader engine for this file" instead of a crash when document file is malformated. This should fix #868.
This commit is contained in:
@@ -56,8 +56,7 @@ function PdfDocument:init()
|
||||
local ok
|
||||
ok, self._document = pcall(pdf.openDocument, self.file, self.mupdf_cache_size)
|
||||
if not ok then
|
||||
self.error_message = self._document -- will contain error message
|
||||
return
|
||||
error(self._document) -- will contain error message
|
||||
end
|
||||
self.is_open = true
|
||||
self.info.has_pages = true
|
||||
@@ -67,6 +66,9 @@ function PdfDocument:init()
|
||||
else
|
||||
self:_readMetadata()
|
||||
end
|
||||
if not (self.info.number_of_pages > 0) then
|
||||
error("No page found in PDF file")
|
||||
end
|
||||
end
|
||||
|
||||
function PdfDocument:unlock(password)
|
||||
|
||||
Reference in New Issue
Block a user