Add a cmdexc.Error
This commit is contained in:
parent
a6c629899e
commit
290d27a064
@ -23,33 +23,33 @@ Defined here to avoid circular dependency hell.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class CommandError(Exception):
|
class Error(Exception):
|
||||||
|
|
||||||
|
"""Base class for all cmdexc errors."""
|
||||||
|
|
||||||
|
|
||||||
|
class CommandError(Error):
|
||||||
|
|
||||||
"""Raised when a command encounters an error while running."""
|
"""Raised when a command encounters an error while running."""
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class CommandMetaError(Exception):
|
class NoSuchCommandError(Error):
|
||||||
|
|
||||||
"""Common base class for exceptions occurring before a command is run."""
|
|
||||||
|
|
||||||
|
|
||||||
class NoSuchCommandError(CommandMetaError):
|
|
||||||
|
|
||||||
"""Raised when a command wasn't found."""
|
"""Raised when a command wasn't found."""
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ArgumentTypeError(CommandMetaError):
|
class ArgumentTypeError(Error):
|
||||||
|
|
||||||
"""Raised when an argument had an invalid type."""
|
"""Raised when an argument had an invalid type."""
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class PrerequisitesError(CommandMetaError):
|
class PrerequisitesError(Error):
|
||||||
|
|
||||||
"""Raised when a cmd can't be used because some prerequisites aren't met.
|
"""Raised when a cmd can't be used because some prerequisites aren't met.
|
||||||
|
|
||||||
|
@ -310,7 +310,7 @@ class CommandRunner(QObject):
|
|||||||
"""Run a command and display exceptions in the statusbar."""
|
"""Run a command and display exceptions in the statusbar."""
|
||||||
try:
|
try:
|
||||||
self.run(text, count)
|
self.run(text, count)
|
||||||
except (cmdexc.CommandMetaError, cmdexc.CommandError) as e:
|
except cmdexc.Error as e:
|
||||||
message.error(str(e), stack=traceback.format_exc())
|
message.error(str(e), stack=traceback.format_exc())
|
||||||
|
|
||||||
@pyqtSlot(str, int)
|
@pyqtSlot(str, int)
|
||||||
@ -322,5 +322,5 @@ class CommandRunner(QObject):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.run(text, count)
|
self.run(text, count)
|
||||||
except (cmdexc.CommandMetaError, cmdexc.CommandError) as e:
|
except cmdexc.Error as e:
|
||||||
message.error(str(e), stack=traceback.format_exc())
|
message.error(str(e), stack=traceback.format_exc())
|
||||||
|
@ -42,7 +42,7 @@ class CommandKeyParser(BaseKeyParser):
|
|||||||
def execute(self, cmdstr, _keytype, count=None):
|
def execute(self, cmdstr, _keytype, count=None):
|
||||||
try:
|
try:
|
||||||
self._commandrunner.run(cmdstr, count)
|
self._commandrunner.run(cmdstr, count)
|
||||||
except (cmdexc.CommandMetaError, cmdexc.CommandError) as e:
|
except cmdexc.Error as e:
|
||||||
message.error(str(e), stack=traceback.format_exc())
|
message.error(str(e), stack=traceback.format_exc())
|
||||||
|
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ class RegisterKeyParser(keyparser.CommandKeyParser):
|
|||||||
else:
|
else:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"{} is not a valid register mode".format(self._mode))
|
"{} is not a valid register mode".format(self._mode))
|
||||||
except (cmdexc.CommandMetaError, cmdexc.CommandError) as err:
|
except cmdexc.Error as err:
|
||||||
message.error(str(err), stack=traceback.format_exc())
|
message.error(str(err), stack=traceback.format_exc())
|
||||||
|
|
||||||
self.request_leave.emit(self._mode, "valid register key", True)
|
self.request_leave.emit(self._mode, "valid register key", True)
|
||||||
|
Loading…
Reference in New Issue
Block a user