diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2013-06-24 14:02:36 +0100 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2013-07-07 18:06:17 +0100 |
commit | c4990d755add6c627ae9f780fd68b16bcca1da05 (patch) | |
tree | 18e42cdbb0d65207ec0b790e3099a7e877cbe3fb | |
parent | f2e51797f6398f51e248908b3006be2e978e1fea (diff) |
introduce CompletionErrors
and use them to handle AddressbookError exceptions
raised by addressbook.lookup
-rw-r--r-- | alot/completion.py | 8 | ||||
-rw-r--r-- | alot/errors.py | 4 |
2 files changed, 10 insertions, 2 deletions
diff --git a/alot/completion.py b/alot/completion.py index fd3bee52..9be62e3f 100644 --- a/alot/completion.py +++ b/alot/completion.py @@ -13,7 +13,8 @@ from alot.buffers import EnvelopeBuffer from alot.settings import settings from alot.utils.booleanaction import BooleanAction from alot.helper import split_commandline - +from alot.addressbooks import AddressbookError +from errors import CompletionError class Completer(object): """base class for completers""" @@ -212,7 +213,10 @@ class AbooksCompleter(Completer): prefix = original[:pos] res = [] for abook in self.abooks: - res = res + abook.lookup(prefix) + try: + res = res + abook.lookup(prefix) + except AddressbookError as e: + raise CompletionError(e) if self.addressesonly: returnlist = [(email, len(email)) for (name, email) in res] else: diff --git a/alot/errors.py b/alot/errors.py index 435a4bf9..9f4bd519 100644 --- a/alot/errors.py +++ b/alot/errors.py @@ -20,3 +20,7 @@ class GPGProblem(Exception): def __init__(self, message, code): self.code = code super(GPGProblem, self).__init__(message) + + +class CompletionError(Exception): + pass |