sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit e49c69f1f61c7b671ce796d59668e4e41fcdbc25
parent 42e7aeaa907444acfcd1e1c30681c30ccb0cf2f1
Author: Michael Stapelberg <michael@stapelberg.de>
Date:   Mon, 15 Feb 2010 19:27:38 +0100

catch xapian query parser exceptions and display them to the user

Diffstat:
M lib/sup/xapian_index.rb | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/sup/xapian_index.rb b/lib/sup/xapian_index.rb
@@ -273,7 +273,12 @@ EOS
     qp.add_valuerangeprocessor(Xapian::NumberValueRangeProcessor.new(DATE_VALUENO, 'date:', true))
     NORMAL_PREFIX.each { |k,vs| vs.each { |v| qp.add_prefix k, v } }
     BOOLEAN_PREFIX.each { |k,vs| vs.each { |v| qp.add_boolean_prefix k, v } }
-    xapian_query = qp.parse_query(subs, Xapian::QueryParser::FLAG_PHRASE|Xapian::QueryParser::FLAG_BOOLEAN|Xapian::QueryParser::FLAG_LOVEHATE|Xapian::QueryParser::FLAG_WILDCARD)
+
+    begin
+      xapian_query = qp.parse_query(subs, Xapian::QueryParser::FLAG_PHRASE|Xapian::QueryParser::FLAG_BOOLEAN|Xapian::QueryParser::FLAG_LOVEHATE|Xapian::QueryParser::FLAG_WILDCARD)
+    rescue RuntimeError => e
+      raise ParseError, "xapian query parser error: #{e}"
+    end
 
     debug "parsed xapian query: #{xapian_query.description}"