summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-02-05 16:52:07 -0800
committerBryan Newbold <bnewbold@robocracy.org>2019-02-05 16:52:07 -0800
commit1a7ef0c7cb8e1b84e24cd75b910e62e613fdc726 (patch)
tree82ac8e3c23c737439a6ae392a1b15dc460b077e9 /python
parentea7dd5403cf531282d81a111cafd20347999fe09 (diff)
downloadfatcat-1a7ef0c7cb8e1b84e24cd75b910e62e613fdc726.tar.gz
fatcat-1a7ef0c7cb8e1b84e24cd75b910e62e613fdc726.zip
add flash to 400 error pages
Diffstat (limited to 'python')
-rw-r--r--python/fatcat_web/search.py8
1 files changed, 6 insertions, 2 deletions
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.<p><code>{}</code>".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)