summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorpazz <patricktotzke@gmail.com>2011-08-09 22:40:41 +0100
committerpazz <patricktotzke@gmail.com>2011-08-09 22:40:41 +0100
commit637802a5d5829ecb9147481d09bbb5c795b8e3d6 (patch)
tree4b9c4c5705b7961c9f8bc4cb9e5cbfd5fe0cf4ca /alot
parent5f260f6d697a347890b79e62d3d5055c481a92fe (diff)
handle bad querystrings
issue #48
Diffstat (limited to 'alot')
-rw-r--r--alot/buffer.py9
-rw-r--r--alot/db.py5
2 files changed, 12 insertions, 2 deletions
diff --git a/alot/buffer.py b/alot/buffer.py
index bac91128..fe500536 100644
--- a/alot/buffer.py
+++ b/alot/buffer.py
@@ -17,6 +17,8 @@ along with notmuch. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2011 Patrick Totzke <patricktotzke@gmail.com>
"""
import urwid
+from notmuch.globals import NotmuchError
+
import widgets
import settings
@@ -144,7 +146,12 @@ class SearchBuffer(Buffer):
self.isinitialized = True
self.result_count = self.dbman.count_messages(self.querystring)
- self.tids = self.dbman.search_thread_ids(self.querystring)
+ try:
+ self.tids = self.dbman.search_thread_ids(self.querystring)
+ except NotmuchError:
+ self.ui.notify('malformed query string: %s' % self.querystring,
+ 'error')
+ self.tids = []
self.threadlist = IteratorWalker(iter(self.tids),
widgets.ThreadlineWidget,
dbman=self.dbman)
diff --git a/alot/db.py b/alot/db.py
index 74c2f405..9832999e 100644
--- a/alot/db.py
+++ b/alot/db.py
@@ -142,7 +142,10 @@ class DBManager:
"""returns the thread with given id as alot.db.Thread object"""
query = self.query('thread:' + tid)
#TODO raise exceptions here in 0<case msgcount>1
- return Thread(self, query.search_threads().next())
+ try:
+ return Thread(self, query.search_threads().next())
+ except:
+ return None
def get_all_tags(self):
"""returns all tags as list of strings"""