##// END OF EJS Templates
whoosh errors don't crash entire app now, just display an error and log exception instead
marcink -
r1303:9773b46e beta
parent child Browse files
Show More
@@ -37,7 +37,7 b' from webhelpers.util import update_param'
37
37
38 from whoosh.index import open_dir, EmptyIndexError
38 from whoosh.index import open_dir, EmptyIndexError
39 from whoosh.qparser import QueryParser, QueryParserError
39 from whoosh.qparser import QueryParser, QueryParserError
40 from whoosh.query import Phrase
40 from whoosh.query import Phrase, Wildcard, Term, Prefix
41
41
42 log = logging.getLogger(__name__)
42 log = logging.getLogger(__name__)
43
43
@@ -79,6 +79,8 b' class SearchController(BaseController):'
79
79
80 if isinstance(query, Phrase):
80 if isinstance(query, Phrase):
81 highlight_items.update(query.words)
81 highlight_items.update(query.words)
82 elif isinstance(query, Prefix):
83 highlight_items.add(query.text)
82 else:
84 else:
83 for i in query.all_terms():
85 for i in query.all_terms():
84 if i[0] == 'content':
86 if i[0] == 'content':
@@ -111,6 +113,9 b' class SearchController(BaseController):'
111 log.error('Empty Index data')
113 log.error('Empty Index data')
112 c.runtime = _('There is no index to search in. '
114 c.runtime = _('There is no index to search in. '
113 'Please run whoosh indexer')
115 'Please run whoosh indexer')
116 except (Exception):
117 log.error(traceback.format_exc())
118 c.runtime = _('An error occurred during this search operation')
114
119
115 # Return a rendered template
120 # Return a rendered template
116 return render('/search/search.html')
121 return render('/search/search.html')
General Comments 0
You need to be logged in to leave comments. Login now