From 80040fc8b076a612cc3d052cd809eb2fb27972c7 Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Mon, 24 Jun 2013 09:22:05 +0100 Subject: handle errors of external cmds in MatchSdtoutAddressbook issue #624 --- alot/addressbooks.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'alot/addressbooks.py') diff --git a/alot/addressbooks.py b/alot/addressbooks.py index 59f093de..890eb0e3 100644 --- a/alot/addressbooks.py +++ b/alot/addressbooks.py @@ -9,6 +9,10 @@ from helper import call_cmd from alot.helper import split_commandstring +class AddressbookError(Exception): + pass + + class AddressBook(object): """can look up email addresses and realnames for contacts. @@ -89,6 +93,13 @@ class MatchSdtoutAddressbook(AddressBook): def lookup(self, prefix): cmdlist = split_commandstring(self.command) resultstring, errmsg, retval = call_cmd(cmdlist + [prefix]) + if retval != 0: + msg = 'abook command "%s" returned with ' % self.command + msg += 'return code %d' % retval + if errmsg: + msg += ':\n%s' % errmsg + raise AddressbookError(msg) + if not resultstring: return [] lines = resultstring.splitlines() -- cgit v1.2.3