aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/fatcat_web/editing_routes.py6
-rw-r--r--python/fatcat_web/routes.py20
-rw-r--r--python/fatcat_web/templates/400.html18
3 files changed, 23 insertions, 21 deletions
diff --git a/python/fatcat_web/editing_routes.py b/python/fatcat_web/editing_routes.py
index e66f29c9..ffce35f3 100644
--- a/python/fatcat_web/editing_routes.py
+++ b/python/fatcat_web/editing_routes.py
@@ -79,8 +79,7 @@ def generic_entity_edit(editgroup_id, entity_type, existing_ident, edit_template
# check that editgroup is edit-able
if editgroup.changelog_index != None:
- flash("Editgroup already merged")
- abort(400)
+ abort(400, "Editgroup already merged")
# fetch entity (if set) or 404
existing = None
@@ -206,8 +205,7 @@ def generic_edit_delete(editgroup_id, entity_type, edit_id):
# check that editgroup is edit-able
if editgroup.changelog_index != None:
- flash("Editgroup already merged")
- abort(400)
+ abort(400, "Editgroup already merged")
# API on behalf of user
user_api = auth_api(session['api_token'])
diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py
index 71946d14..6f3ec21b 100644
--- a/python/fatcat_web/routes.py
+++ b/python/fatcat_web/routes.py
@@ -503,8 +503,7 @@ def editgroup_create_annotation(ident):
try:
eg = user_api.get_editgroup(str(ident))
if eg.changelog_index:
- flash("Editgroup already accepted")
- abort(400)
+ abort(400, "Editgroup already accepted")
ega = EditgroupAnnotation(
comment_markdown=comment_markdown,
extra=None,
@@ -525,8 +524,7 @@ def editgroup_accept(ident):
try:
eg = user_api.get_editgroup(str(ident))
if eg.changelog_index:
- flash("Editgroup already accepted")
- abort(400)
+ abort(400, "Editgroup already accepted")
user_api.accept_editgroup(str(ident))
except ApiException as ae:
app.log.info(ae)
@@ -543,8 +541,7 @@ def editgroup_unsubmit(ident):
try:
eg = user_api.get_editgroup(str(ident))
if eg.changelog_index:
- flash("Editgroup already accepted")
- abort(400)
+ abort(400, "Editgroup already accepted")
user_api.update_editgroup(eg.editgroup_id, eg, submit=False)
except ApiException as ae:
app.log.info(ae)
@@ -561,8 +558,7 @@ def editgroup_submit(ident):
try:
eg = user_api.get_editgroup(str(ident))
if eg.changelog_index:
- flash("Editgroup already accepted")
- abort(400)
+ abort(400, "Editgroup already accepted")
user_api.update_editgroup(eg.editgroup_id, eg, submit=True)
except ApiException as ae:
app.log.info(ae)
@@ -762,8 +758,7 @@ def stats_json():
@crossdomain(origin='*',headers=['access-control-allow-origin','Content-Type'])
def container_issnl_stats(issnl):
if not (len(issnl) == 9 and issnl[4] == '-'):
- flash("Not a valid ISSN-L: {}".format(issnl))
- abort(400)
+ abort(400, "Not a valid ISSN-L: {}".format(issnl))
try:
container = api.lookup_container(issnl=issnl)
except ApiException as ae:
@@ -917,8 +912,7 @@ def create_auth_token():
duration_seconds = int(duration_seconds)
assert duration_seconds >= 1
except (ValueError, AssertionError):
- flash("duration_seconds must be a positive non-zero integer")
- abort(400)
+ abort(400, "duration_seconds must be a positive non-zero integer")
# check user's auth. api_token and editor_id are signed together in session
# cookie, so if api_token is valid editor_id is assumed to match. If that
@@ -986,7 +980,7 @@ def page_method_not_allowed(e):
@app.errorhandler(400)
def page_bad_request(e):
- return render_template('400.html'), 400
+ return render_template('400.html', err=e), 400
@app.errorhandler(409)
def page_edit_conflict(e):
diff --git a/python/fatcat_web/templates/400.html b/python/fatcat_web/templates/400.html
index f2659ca2..21f98aad 100644
--- a/python/fatcat_web/templates/400.html
+++ b/python/fatcat_web/templates/400.html
@@ -4,10 +4,20 @@
<center>
<div style="font-size: 8em;">400</div>
<div style="font-size: 3em;">Bad Request</div>
-
-<p>Wasn't able to handle the request, either due to incorrect or unexpected
-input. Usually more context should be available; if you hit this page it means
-you've discovered a new corner case!
</center>
+<div class="ui icon error message">
+ <i class="ban icon"></i>
+ <div class="content">
+ <div class="header"></div>
+ {% if err and err.description %}
+ <p>{{ err.description }}
+ {% else %}
+ <p>Wasn't able to handle the request, either due to incorrect or unexpected
+ input. Usually more context should be available; if you hit this page it means
+ you've discovered a new corner case!
+ {% endif %}
+ </div>
+</div>
+
{% endblock %}