pdfjs: throw PDFJSNotFound from None

Otherwise the stacktrace might be confusing since it will show the
FileNotFoundException as the causing error, which is not true (it just
happens to be the last checked place).

The .path attribute was added so that we still have the requested path
in the error log.

See #1280.
This commit is contained in:
Daniel Schadt 2016-02-04 21:11:20 +01:00
parent 83dc390808
commit da4f69cf72

View File

@ -29,9 +29,16 @@ from qutebrowser.utils import utils
class PDFJSNotFound(Exception):
"""Raised when no pdf.js installation is found."""
"""Raised when no pdf.js installation is found.
pass
Attributes:
path: path of the file that was requested but not found.
"""
def __init__(self, path):
self.path = path
message = "Path '{}' not found".format(path)
super().__init__(message)
def generate_pdfjs_page(url):
@ -129,7 +136,7 @@ def get_pdfjs_res_and_path(path):
try:
content = utils.read_file(res_path, binary=True)
except FileNotFoundError:
raise PDFJSNotFound
raise PDFJSNotFound(path) from None
try:
# Might be script/html or might be binary