summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Ulrich Niedermann <hun@n-dimensional.de>2008-06-30 21:06:45 +0200
committerHans Ulrich Niedermann <hun@n-dimensional.de>2008-07-15 12:28:55 +0200
commit09e6bfb4e1d2a33fcab66b04024911a3f6eac726 (patch)
tree7a388e24f38f2359c2e506080fe3049878303f3f
parentf701319cdc4ceffaaf2faea551da46b03fa2bdfc (diff)
downloadnbb-09e6bfb4e1d2a33fcab66b04024911a3f6eac726.tar.gz
nbb-09e6bfb4e1d2a33fcab66b04024911a3f6eac726.tar.xz
nbb-09e6bfb4e1d2a33fcab66b04024911a3f6eac726.zip
Introduce UnknownException and use it
-rw-r--r--src/nbblib/commands.py13
1 files 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)