aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/cmdutil.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-07-11 06:39:48 -0400
committerW. Trevor King <wking@drexel.edu>2009-07-11 06:39:48 -0400
commit71579e9906be1da2ec2e53a53beebece832cd04e (patch)
treed0f0f0a8aaff5d812b77b78f82fda9ccabd5c7fe /libbe/cmdutil.py
parente5c0d5f2f3f7637cad6baca9e33778d0c054195d (diff)
parentf0300038113e2754d83ee73f32a51072ad9b1f3b (diff)
downloadbugseverywhere-71579e9906be1da2ec2e53a53beebece832cd04e.tar.gz
Merged "be comment --xml" code from home.
Diffstat (limited to 'libbe/cmdutil.py')
-rw-r--r--libbe/cmdutil.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/libbe/cmdutil.py b/libbe/cmdutil.py
index 0dd8ad0..ada0423 100644
--- a/libbe/cmdutil.py
+++ b/libbe/cmdutil.py
@@ -32,10 +32,10 @@ class UserError(Exception):
def __init__(self, msg):
Exception.__init__(self, msg)
-class UserErrorWrap(UserError):
- def __init__(self, exception):
- UserError.__init__(self, str(exception))
- self.exception = exception
+class UnknownCommand(UserError):
+ def __init__(self, cmd):
+ Exception.__init__(self, "Unknown command '%s'" % cmd)
+ self.cmd = cmd
class UsageError(Exception):
pass
@@ -56,15 +56,17 @@ def iter_commands():
def get_command(command_name):
"""Retrieves the module for a user command
- >>> get_command("asdf")
- Traceback (most recent call last):
- UserError: Unknown command asdf
+ >>> try:
+ ... get_command("asdf")
+ ... except UnknownCommand, e:
+ ... print e
+ Unknown command asdf
>>> repr(get_command("list")).startswith("<module 'becommands.list' from ")
True
"""
cmd = plugin.get_plugin("becommands", command_name.replace("-", "_"))
if cmd is None:
- raise UserError("Unknown command %s" % command_name)
+ raise UnknownCommand(command_name)
return cmd