Move QuteSchemeError to qutescheme
This commit is contained in:
parent
aa71c9ae58
commit
71bc5bb943
@ -56,6 +56,24 @@ def add_handler(name):
|
|||||||
"""Add a handler to the qute: scheme."""
|
"""Add a handler to the qute: scheme."""
|
||||||
def namedecorator(function):
|
def namedecorator(function):
|
||||||
_HANDLERS[name] = function
|
_HANDLERS[name] = function
|
||||||
|
class QuteSchemeError(Exception):
|
||||||
|
|
||||||
|
"""Exception to signal that a handler should return an ErrorReply.
|
||||||
|
|
||||||
|
Attributes correspond to the arguments in
|
||||||
|
networkreply.ErrorNetworkReply.
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
errorstring: Error string to print.
|
||||||
|
error: Numerical error value.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, errorstring, error):
|
||||||
|
self.errorstring = errorstring
|
||||||
|
self.error = error
|
||||||
|
super().__init__(errorstring)
|
||||||
|
|
||||||
|
|
||||||
return function
|
return function
|
||||||
return namedecorator
|
return namedecorator
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ class QuteSchemeHandler(schemehandler.SchemeHandler):
|
|||||||
return networkreply.ErrorNetworkReply(
|
return networkreply.ErrorNetworkReply(
|
||||||
request, str(e), QNetworkReply.ContentNotFoundError,
|
request, str(e), QNetworkReply.ContentNotFoundError,
|
||||||
self.parent())
|
self.parent())
|
||||||
except QuteSchemeError as e:
|
except qutescheme.QuteSchemeError as e:
|
||||||
return networkreply.ErrorNetworkReply(request, e.errorstring,
|
return networkreply.ErrorNetworkReply(request, e.errorstring,
|
||||||
e.error, self.parent())
|
e.error, self.parent())
|
||||||
|
|
||||||
@ -123,5 +123,6 @@ def qute_pdfjs(url):
|
|||||||
# information, as the failed pdfjs requests are still in the log.
|
# information, as the failed pdfjs requests are still in the log.
|
||||||
log.misc.warning(
|
log.misc.warning(
|
||||||
"pdfjs resource requested but not found: {}".format(e.path))
|
"pdfjs resource requested but not found: {}".format(e.path))
|
||||||
raise QuteSchemeError("Can't find pdfjs resource '{}'".format(e.path),
|
raise qutescheme.QuteSchemeError("Can't find pdfjs resource "
|
||||||
QNetworkReply.ContentNotFoundError)
|
"'{}'".format(e.path),
|
||||||
|
QNetworkReply.ContentNotFoundError)
|
||||||
|
Loading…
Reference in New Issue
Block a user