aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2020-09-17 21:11:05 -0700
committerBryan Newbold <bnewbold@robocracy.org>2020-09-17 21:11:05 -0700
commit2812b3a363ec41eb11a35affb128f66b39d40e6d (patch)
treeb9165beea5f0dc259582a4db875aa20cff3e04f0 /python
parent8187720f503967ad68ab07fb25b36f554663e1c3 (diff)
downloadfatcat-2812b3a363ec41eb11a35affb128f66b39d40e6d.tar.gz
fatcat-2812b3a363ec41eb11a35affb128f66b39d40e6d.zip
web: handle unknown CSL style as a cleaner 400 page
Diffstat (limited to 'python')
-rw-r--r--python/fatcat_web/routes.py6
-rw-r--r--python/fatcat_web/templates/400.html2
2 files changed, 7 insertions, 1 deletions
diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py
index 924a4d4c..02b5258a 100644
--- a/python/fatcat_web/routes.py
+++ b/python/fatcat_web/routes.py
@@ -1,6 +1,7 @@
import os
import json
+import citeproc_styles
from flask import render_template, make_response, send_from_directory, \
request, url_for, abort, redirect, jsonify, session, flash, Response
from flask_login import login_required
@@ -962,7 +963,10 @@ def release_citeproc(ident):
except ApiException as ae:
raise ae
csl = release_to_csl(entity)
- cite = citeproc_csl(csl, style, is_html)
+ try:
+ cite = citeproc_csl(csl, style, is_html)
+ except citeproc_styles.StyleNotFoundError as e:
+ abort(400, e)
if is_html:
return Response(cite)
elif style == "csl-json":
diff --git a/python/fatcat_web/templates/400.html b/python/fatcat_web/templates/400.html
index 21f98aad..c0a00652 100644
--- a/python/fatcat_web/templates/400.html
+++ b/python/fatcat_web/templates/400.html
@@ -12,6 +12,8 @@
<div class="header"></div>
{% if err and err.description %}
<p>{{ err.description }}
+ {% elif err %}
+ <p>{{ err }}
{% 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