Add a cmdexc.Error

This commit is contained in:
Florian Bruhin 2017-06-19 16:35:57 +02:00
parent a6c629899e
commit 290d27a064
4 changed files with 13 additions and 13 deletions

View File

@ -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."""
pass
class CommandMetaError(Exception):
"""Common base class for exceptions occurring before a command is run."""
class NoSuchCommandError(CommandMetaError):
class NoSuchCommandError(Error):
"""Raised when a command wasn't found."""
pass
class ArgumentTypeError(CommandMetaError):
class ArgumentTypeError(Error):
"""Raised when an argument had an invalid type."""
pass
class PrerequisitesError(CommandMetaError):
class PrerequisitesError(Error):
"""Raised when a cmd can't be used because some prerequisites aren't met.

View File

@ -310,7 +310,7 @@ class CommandRunner(QObject):
"""Run a command and display exceptions in the statusbar."""
try:
self.run(text, count)
except (cmdexc.CommandMetaError, cmdexc.CommandError) as e:
except cmdexc.Error as e:
message.error(str(e), stack=traceback.format_exc())
@pyqtSlot(str, int)
@ -322,5 +322,5 @@ class CommandRunner(QObject):
"""
try:
self.run(text, count)
except (cmdexc.CommandMetaError, cmdexc.CommandError) as e:
except cmdexc.Error as e:
message.error(str(e), stack=traceback.format_exc())

View File

@ -42,7 +42,7 @@ class CommandKeyParser(BaseKeyParser):
def execute(self, cmdstr, _keytype, count=None):
try:
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())

View File

@ -316,7 +316,7 @@ class RegisterKeyParser(keyparser.CommandKeyParser):
else:
raise ValueError(
"{} 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())
self.request_leave.emit(self._mode, "valid register key", True)