Show exception stack when handling cmdexc errors.
This commit is contained in:
parent
b6abada50a
commit
4a551a6758
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
import inspect
|
import inspect
|
||||||
import collections
|
import collections
|
||||||
|
import traceback
|
||||||
|
|
||||||
from PyQt5.QtWebKit import QWebSettings
|
from PyQt5.QtWebKit import QWebSettings
|
||||||
|
|
||||||
@ -493,7 +494,8 @@ class Command:
|
|||||||
try:
|
try:
|
||||||
self.namespace = self.parser.parse_args(args)
|
self.namespace = self.parser.parse_args(args)
|
||||||
except argparser.ArgumentParserError as e:
|
except argparser.ArgumentParserError as e:
|
||||||
message.error(win_id, '{}: {}'.format(self.name, e))
|
message.error(win_id, '{}: {}'.format(self.name, e),
|
||||||
|
stack=traceback.format_exc())
|
||||||
return
|
return
|
||||||
except argparser.ArgumentParserExit as e:
|
except argparser.ArgumentParserExit as e:
|
||||||
log.commands.debug("argparser exited with status {}: {}".format(
|
log.commands.debug("argparser exited with status {}: {}".format(
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
"""Module containing command managers (SearchRunner and CommandRunner)."""
|
"""Module containing command managers (SearchRunner and CommandRunner)."""
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
|
import traceback
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtSlot, QUrl, QObject
|
from PyQt5.QtCore import pyqtSlot, QUrl, QObject
|
||||||
|
|
||||||
@ -264,7 +265,8 @@ class CommandRunner(QObject):
|
|||||||
try:
|
try:
|
||||||
self.run(text, count)
|
self.run(text, count)
|
||||||
except (cmdexc.CommandMetaError, cmdexc.CommandError) as e:
|
except (cmdexc.CommandMetaError, cmdexc.CommandError) as e:
|
||||||
message.error(self._win_id, e, immediately=True)
|
message.error(self._win_id, e, immediately=True,
|
||||||
|
stack=traceback.format_exc())
|
||||||
|
|
||||||
@pyqtSlot(str, int)
|
@pyqtSlot(str, int)
|
||||||
def run_safely_init(self, text, count=None):
|
def run_safely_init(self, text, count=None):
|
||||||
@ -276,4 +278,4 @@ class CommandRunner(QObject):
|
|||||||
try:
|
try:
|
||||||
self.run(text, count)
|
self.run(text, count)
|
||||||
except (cmdexc.CommandMetaError, cmdexc.CommandError) as e:
|
except (cmdexc.CommandMetaError, cmdexc.CommandError) as e:
|
||||||
message.error(self._win_id, e)
|
message.error(self._win_id, e, stack=traceback.format_exc())
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
"""Advanced keyparsers."""
|
"""Advanced keyparsers."""
|
||||||
|
|
||||||
|
import traceback
|
||||||
|
|
||||||
from qutebrowser.keyinput.basekeyparser import BaseKeyParser
|
from qutebrowser.keyinput.basekeyparser import BaseKeyParser
|
||||||
from qutebrowser.utils import message, utils
|
from qutebrowser.utils import message, utils
|
||||||
from qutebrowser.commands import runners, cmdexc
|
from qutebrowser.commands import runners, cmdexc
|
||||||
@ -41,7 +43,8 @@ class CommandKeyParser(BaseKeyParser):
|
|||||||
try:
|
try:
|
||||||
self._commandrunner.run(cmdstr, count)
|
self._commandrunner.run(cmdstr, count)
|
||||||
except (cmdexc.CommandMetaError, cmdexc.CommandError) as e:
|
except (cmdexc.CommandMetaError, cmdexc.CommandError) as e:
|
||||||
message.error(self._win_id, e, immediately=True)
|
message.error(self._win_id, e, immediately=True,
|
||||||
|
stack=traceback.format_exc())
|
||||||
|
|
||||||
|
|
||||||
class PassthroughKeyParser(CommandKeyParser):
|
class PassthroughKeyParser(CommandKeyParser):
|
||||||
|
@ -116,14 +116,16 @@ def on_focus_changed():
|
|||||||
getattr(bridge, msg.method_name)(text, *msg.args, **msg.kwargs)
|
getattr(bridge, msg.method_name)(text, *msg.args, **msg.kwargs)
|
||||||
|
|
||||||
|
|
||||||
def error(win_id, message, immediately=False):
|
def error(win_id, message, immediately=False, *, stack=None):
|
||||||
"""Convenience function to display an error message in the statusbar.
|
"""Convenience function to display an error message in the statusbar.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
win_id: The ID of the window which is calling this function.
|
win_id: The ID of the window which is calling this function.
|
||||||
others: See MessageBridge.error.
|
others: See MessageBridge.error.
|
||||||
|
stack: The stack trace to show.
|
||||||
"""
|
"""
|
||||||
stack = ''.join(traceback.format_stack())
|
if stack is None:
|
||||||
|
stack = ''.join(traceback.format_stack())
|
||||||
log.message.debug("Error message stack:\n{}".format(stack))
|
log.message.debug("Error message stack:\n{}".format(stack))
|
||||||
_wrapper(win_id, 'error', message, immediately)
|
_wrapper(win_id, 'error', message, immediately)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user