From 1a7ef0c7cb8e1b84e24cd75b910e62e613fdc726 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 5 Feb 2019 16:52:07 -0800 Subject: add flash to 400 error pages --- python/fatcat_web/search.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'python') diff --git a/python/fatcat_web/search.py b/python/fatcat_web/search.py index 41009e19..5c278c21 100644 --- a/python/fatcat_web/search.py +++ b/python/fatcat_web/search.py @@ -1,6 +1,6 @@ import requests -from flask import abort +from flask import abort, flash from fatcat_web import app """ @@ -36,7 +36,11 @@ def do_search(q, limit=50, fulltext_only=True): (app.config['ELASTICSEARCH_BACKEND'], app.config['ELASTICSEARCH_RELEASE_INDEX']), json=search_request) - if resp.status_code != 200: + if resp.status_code == 400: + print("elasticsearch 400: " + str(resp.content)) + flash("Search query failed to parse; you might need to use quotes.

{}".format(resp.content)) + abort(resp.status_code) + elif resp.status_code != 200: print("elasticsearch non-200 status code: " + str(resp.status_code)) print(resp.content) abort(resp.status_code) -- cgit v1.2.3