From da4f69cf7219d0c1c6116289a64a07239f3a2c23 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Thu, 4 Feb 2016 21:11:20 +0100 Subject: [PATCH] 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. --- qutebrowser/browser/pdfjs.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/qutebrowser/browser/pdfjs.py b/qutebrowser/browser/pdfjs.py index b38d6edd1..aeb6435af 100644 --- a/qutebrowser/browser/pdfjs.py +++ b/qutebrowser/browser/pdfjs.py @@ -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