aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/command/base.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2011-05-25 10:30:19 -0400
committerW. Trevor King <wking@drexel.edu>2011-05-25 10:30:19 -0400
commit0d5c9c68e947617c9d073d5f19351bdd8f3866db (patch)
tree637515c14882ba725a60902022409203f1fa7bcc /libbe/command/base.py
parentad098c3d1bef935350cee87eb585ba7597293b0a (diff)
downloadbugseverywhere-0d5c9c68e947617c9d073d5f19351bdd8f3866db.tar.gz
Attach ImportError message to UnknownCommand to aid debugging.
Diffstat (limited to 'libbe/command/base.py')
-rw-r--r--libbe/command/base.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/libbe/command/base.py b/libbe/command/base.py
index 4ab4a21..311791f 100644
--- a/libbe/command/base.py
+++ b/libbe/command/base.py
@@ -54,10 +54,15 @@ class UsageError (UserError):
class UnknownCommand (UsageError):
- def __init__(self, command_name):
+ def __init__(self, command_name, message=None):
+ uc_message = "Unknown command '%s'" % command_name
+ if message is None:
+ message = uc_message
+ else:
+ message = '%s\n(%s)' % (uc_message, message)
super(UnknownCommand, self).__init__(
command_name=command_name,
- message="Unknown command '%s'" % command_name)
+ message=message)
def get_command(command_name):
@@ -75,7 +80,7 @@ def get_command(command_name):
cmd = libbe.util.plugin.import_by_name(
'libbe.command.%s' % command_name.replace("-", "_"))
except ImportError, e:
- raise UnknownCommand(command_name)
+ raise UnknownCommand(command_name, message=unicode(e))
return cmd
def get_command_class(module=None, command_name=None):