# HG changeset patch # User Mads Kiilerich # Date 2018-12-23 21:16:07 # Node ID d5ab6db3b9e26418319506f1b837cde966e625c6 # Parent 8b6e87245e57e9b3d1f804505d494292d676c44a search: better messaging when the index hasn't been built yet Improve the situation around the "Please run whoosh indexer" message. 1. It is not a situation that justifies logging a stack trace. 2. Don't just say "whoosh indexer" - it actually has a name: kallithea-cli index-create . 3. Don't report server side commands in the user interface. diff --git a/kallithea/controllers/search.py b/kallithea/controllers/search.py --- a/kallithea/controllers/search.py +++ b/kallithea/controllers/search.py @@ -136,10 +136,8 @@ class SearchController(BaseRepoControlle c.runtime = _('Invalid search query. Try quoting it.') searcher.close() except EmptyIndexError: - log.error(traceback.format_exc()) - log.error('Empty Index data') - c.runtime = _('There is no index to search in. ' - 'Please run whoosh indexer') + log.error("Empty search index - run 'kallithea-cli index-create' regularly") + c.runtime = _('The server has no search index.') except Exception: log.error(traceback.format_exc()) c.runtime = _('An error occurred during search operation.') diff --git a/kallithea/tests/functional/test_search.py b/kallithea/tests/functional/test_search.py --- a/kallithea/tests/functional/test_search.py +++ b/kallithea/tests/functional/test_search.py @@ -24,8 +24,7 @@ class TestSearchController(TestControlle with mock.patch('kallithea.controllers.search.config', config_mock): response = self.app.get(url(controller='search', action='index'), {'q': HG_REPO}) - response.mustcontain('There is no index to search in. ' - 'Please run whoosh indexer') + response.mustcontain('The server has no search index.') def test_normal_search(self): self.log_user()