X-Git-Url: https://git.llucax.com/software/pymin.git/blobdiff_plain/b33b3ccf6aedaec3d33968d126131e3690319b90..892ae599bab9c942d7b8aaa0530c3b52841a3a29:/dispatcher.py?ds=sidebyside diff --git a/dispatcher.py b/dispatcher.py index 29cff6e..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 ' '.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