aboutsummaryrefslogtreecommitdiffstats
path: root/libbe
diff options
context:
space:
mode:
Diffstat (limited to 'libbe')
-rw-r--r--libbe/bugdir.py8
-rw-r--r--libbe/cmdutil.py9
2 files changed, 16 insertions, 1 deletions
diff --git a/libbe/bugdir.py b/libbe/bugdir.py
index 6e020ee..f7345fd 100644
--- a/libbe/bugdir.py
+++ b/libbe/bugdir.py
@@ -62,6 +62,12 @@ class MultipleBugMatches(ValueError):
self.shortname = shortname
self.matches = matches
+class NoBugMatches(KeyError):
+ def __init__(self, shortname):
+ msg = "No bug matches %s" % shortname
+ KeyError.__init__(self, msg)
+ self.shortname = shortname
+
TREE_VERSION_STRING = "Bugs Everywhere Tree 1 0\n"
@@ -530,7 +536,7 @@ settings easy. Don't set this attribute. Set .rcs instead, and
raise MultipleBugMatches(shortname, matches)
if len(matches) == 1:
return self.bug_from_uuid(matches[0])
- raise KeyError("No bug matches %s" % shortname)
+ raise NoBugMatches(shortname)
def bug_from_uuid(self, uuid):
if not self.has_bug(uuid):
diff --git a/libbe/cmdutil.py b/libbe/cmdutil.py
index 853a75a..35d2f9e 100644
--- a/libbe/cmdutil.py
+++ b/libbe/cmdutil.py
@@ -206,6 +206,15 @@ def underlined(instring):
return "%s\n%s" % (instring, "="*len(instring))
+def bug_from_shortname(bugdir, shortname):
+ """
+ Exception translation for the command-line interface.
+ """
+ try:
+ bug = bugdir.bug_from_shortname(shortname)
+ except (bugdir.MultipleBugMatches, bugdir.NoBugMatches), e:
+ raise UserError(e.message)
+ return bug
def _test():
import doctest