From 09e6bfb4e1d2a33fcab66b04024911a3f6eac726 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Mon, 30 Jun 2008 21:06:45 +0200 Subject: Introduce UnknownException and use it --- src/nbblib/commands.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/nbblib/commands.py b/src/nbblib/commands.py index 1b50dc3..0b0df31 100644 --- a/src/nbblib/commands.py +++ b/src/nbblib/commands.py @@ -331,6 +331,13 @@ class ConfigCommand(SourceClassCommand): # Commands ######################################################################## +class UnknownCommand(Exception): + def __init__(self, cmd): + super(UnknownCommand, self).__init__() + self.cmd = cmd + def __str__(self): + return "Fatal: Unknown command '%(cmd)s'" % self.__dict__ + class NBB_Command(object): def __init__(self, cmd, cmdargs, context): if Command.plugins.has_key(cmd): @@ -342,8 +349,8 @@ class NBB_Command(object): sys.exit(2) except progutils.ProgramRunError, e: print "%(prog)s: Fatal:" % context, e - print "Program aborted." + sys.exit(3) else: - print "Fatal: Unknown command '%s'" % cmd - raise NotImplementedError() + print "%(prog)s:" % context, UnknownCommand(cmd) + sys.exit(2) -- cgit