summaryrefslogtreecommitdiffstats
path: root/python/fatcat_web
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-08-22 23:51:34 +0200
committerBryan Newbold <bnewbold@robocracy.org>2019-08-22 23:51:34 +0200
commitd1a8d1a9845e74e7dc4501cb609ebae464b48a01 (patch)
treef9b1d157bc815532b36b10e78d64d7eb357b3bac /python/fatcat_web
parentfbc03b9bcce0fb5066da574021744ccae2f28b9e (diff)
downloadfatcat-d1a8d1a9845e74e7dc4501cb609ebae464b48a01.tar.gz
fatcat-d1a8d1a9845e74e7dc4501cb609ebae464b48a01.zip
container issnl: handle invalid ISSN-L better, and fix except blocks
Diffstat (limited to 'python/fatcat_web')
-rw-r--r--python/fatcat_web/routes.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py
index 126bcdd0..5789dc48 100644
--- a/python/fatcat_web/routes.py
+++ b/python/fatcat_web/routes.py
@@ -686,9 +686,12 @@ def stats_json():
@app.route('/container/issnl/<issnl>/stats.json', methods=['GET', 'OPTIONS'])
@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)
try:
container = api.lookup_container(issnl=issnl)
- except Exception as ae:
+ except ApiException as ae:
abort(ae.status)
try:
stats = get_elastic_container_stats(container.ident, issnl=container.issnl)
@@ -702,7 +705,7 @@ def container_issnl_stats(issnl):
def container_ident_stats(ident):
try:
container = api.get_container(ident)
- except Exception as ae:
+ except ApiException as ae:
abort(ae.status)
try:
stats = get_elastic_container_stats(container.ident, issnl=container.issnl)