Remove exception handling code for qutescheme.
The exceptions now get handled by @prevent_exceptions on the createRequest method of the NetworkManager, causing the exception handler to pop up properly.
This commit is contained in:
parent
3bded60ba6
commit
cef1dfe368
@ -55,36 +55,23 @@ class QuteSchemeHandler(schemehandler.SchemeHandler):
|
|||||||
Return:
|
Return:
|
||||||
A QNetworkReply.
|
A QNetworkReply.
|
||||||
"""
|
"""
|
||||||
|
path = request.url().path()
|
||||||
|
# An url like "qute:foo" is split as "scheme:path", not
|
||||||
|
# "scheme:host".
|
||||||
|
logutils.misc.debug("url: {}, path: {}".format(
|
||||||
|
request.url().toDisplayString(), path))
|
||||||
try:
|
try:
|
||||||
path = request.url().path()
|
handler = getattr(QuteHandlers, path)
|
||||||
# An url like "qute:foo" is split as "scheme:path", not
|
except AttributeError:
|
||||||
# "scheme:host".
|
errorstr = "No handler found for {}!".format(
|
||||||
logutils.misc.debug("url: {}, path: {}".format(
|
request.url().toDisplayString())
|
||||||
request.url().toDisplayString(), path))
|
return schemehandler.ErrorNetworkReply(
|
||||||
try:
|
request, errorstr, QNetworkReply.ContentNotFoundError,
|
||||||
handler = getattr(QuteHandlers, path)
|
self.parent())
|
||||||
except AttributeError:
|
else:
|
||||||
errorstr = "No handler found for {}!".format(
|
data = handler()
|
||||||
request.url().toDisplayString())
|
return schemehandler.SpecialNetworkReply(
|
||||||
return schemehandler.ErrorNetworkReply(
|
request, data, 'text/html', self.parent())
|
||||||
request, errorstr, QNetworkReply.ContentNotFoundError,
|
|
||||||
self.parent())
|
|
||||||
else:
|
|
||||||
data = handler()
|
|
||||||
return schemehandler.SpecialNetworkReply(
|
|
||||||
request, data, 'text/html', self.parent())
|
|
||||||
except: # pylint: disable=bare-except
|
|
||||||
# WORKAROUND
|
|
||||||
# Any exception raised in here will trigger a segfault.
|
|
||||||
# To prevent this, we return a page with the exception info.
|
|
||||||
# FIXME: We should report this to PyQt upstream.
|
|
||||||
text = "Exception in QuteSchemeHandler.createRequest:\n\n"
|
|
||||||
text += traceback.format_exc()
|
|
||||||
text += ("\nPlease use :report to report a bug and add the "
|
|
||||||
"information printed here by hand.")
|
|
||||||
data = text.encode('utf-8')
|
|
||||||
return schemehandler.SpecialNetworkReply(
|
|
||||||
request, data, 'text/plain', self.parent())
|
|
||||||
|
|
||||||
|
|
||||||
class QuteHandlers:
|
class QuteHandlers:
|
||||||
|
Loading…
Reference in New Issue
Block a user