diff --git a/searx/templates/oscar/base.html b/searx/templates/oscar/base.html
index 81d4febcf..220f5f8b1 100644
--- a/searx/templates/oscar/base.html
+++ b/searx/templates/oscar/base.html
@@ -1,3 +1,4 @@
+{% from 'oscar/macros.html' import icon %}
@@ -54,6 +55,20 @@
{% include 'oscar/navbar.html' %}
+ {% if errors %}
+
+
+
{{ icon('info-sign') }} {{ _('Error!') }}
+
+ {% for message in errors %}
+ - {{ message }}
+ {% endfor %}
+
+
+ {% endif %}
{% block site_alert_error %}
{% endblock %}
diff --git a/searx/webapp.py b/searx/webapp.py
index 7d5adaf07..68902a6cd 100644
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -344,6 +344,8 @@ def render(template_name, override_theme=None, **kwargs):
kwargs['cookies'] = request.cookies
+ kwargs['errors'] = request.errors
+
kwargs['instance_name'] = settings['general']['instance_name']
kwargs['results_on_new_tab'] = request.preferences.get_value('results_on_new_tab')
@@ -364,15 +366,16 @@ def render(template_name, override_theme=None, **kwargs):
@app.before_request
def pre_request():
- # merge GET, POST vars
+ request.errors = []
+
preferences = Preferences(themes, categories.keys(), engines, plugins)
try:
preferences.parse_cookies(request.cookies)
except:
- # TODO throw error message to the user
- logger.warning('Invalid config')
+ request.errors.append(gettext('Invalid settings, please edit your preferences'))
request.preferences = preferences
+ # merge GET, POST vars
# request.form
request.form = dict(request.form.items())
for k, v in request.args.items():
@@ -397,7 +400,7 @@ def index():
Supported outputs: html, json, csv, rss.
"""
- if not request.args and not request.form:
+ if request.form.get('q') is None:
return render(
'index.html',
)
@@ -410,7 +413,8 @@ def index():
# search = Search(search_query) # without plugins
search = SearchWithPlugins(search_query, request)
result_container = search.search()
- except Exception:
+ except:
+ request.errors.append(gettext('search error'))
logger.exception('search error')
return render(
'index.html',
@@ -573,7 +577,7 @@ def preferences():
try:
request.preferences.parse_form(request.form)
except ValidationException:
- # TODO use flash feature of flask
+ request.errors.append(gettext('Invalid settings, please edit your preferences'))
return resp
return request.preferences.save(resp)