X-Git-Url: https://git.llucax.com/software/pymin.git/blobdiff_plain/c9db2312caca9ab1bd655a74bdcb29680b70cbb1..28063e4b7779eff7ac0fa5c9939545d2091ef24c:/dispatcher.py diff --git a/dispatcher.py b/dispatcher.py index 0284da5..b78db93 100644 --- a/dispatcher.py +++ b/dispatcher.py @@ -18,16 +18,17 @@ class Error(RuntimeError): command - is the command that raised the exception, expressed as a list of paths (or subcommands). """ + pass - def __init__(self, command): - r"""Initialize the Error object. +class HandlerError(Error): + r""" + HandlerError(command) -> HandlerError instance :: Base handlers exception. - See Error class documentation for more info. - """ - self.command = command + All exceptions raised by the handlers should inherit from this one, so + dispatching errors could be separated from real programming errors (bugs). + """ + pass - def __str__(self): - return 'Command not found: "%s"' % ' '.join(self.command) class CommandNotFoundError(Error): r""" @@ -36,7 +37,16 @@ class CommandNotFoundError(Error): This exception is raised when the command received can't be dispatched because there is no handlers to process it. """ - pass + + def __init__(self, command): + r"""Initialize the Error object. + + See Error class documentation for more info. + """ + self.command = command + + def __str__(self): + return 'Command not found: "%s"' % ' '.join(self.command) def handler(f): f._dispatcher_handler = True