From 1b9f7608b14d730519cdc572993de1b7ad6d1362 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Wed, 14 Jun 2017 22:48:50 -0700 Subject: [PATCH] Send more jsonified exceptions instead of just 500. --- .../etiquette_flask/etiquette_flask.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/frontends/etiquette_flask/etiquette_flask/etiquette_flask.py b/frontends/etiquette_flask/etiquette_flask/etiquette_flask.py index cb0bedd..149fd5b 100644 --- a/frontends/etiquette_flask/etiquette_flask/etiquette_flask.py +++ b/frontends/etiquette_flask/etiquette_flask/etiquette_flask.py @@ -491,7 +491,12 @@ def post_album_edit(albumid): title = request.form.get('title', None) description = request.form.get('description', None) - album.edit(title=title, description=description) + try: + album.edit(title=title, description=description) + except etiquette.exceptions.EtiquetteException as e: + response = etiquette.jsonify.exception(e) + response = jsonify.make_json_response(response, status=400) + flask.abort(response) response = etiquette.jsonify.album(album, minimal=True) return jsonify.make_json_response(response) @@ -544,7 +549,12 @@ def get_bookmarks_json(): def post_bookmarks_create(): url = request.form['url'] title = request.form.get('title', None) - bookmark = P.new_bookmark(url=url, title=title) + try: + bookmark = P.new_bookmark(url=url, title=title) + except etiquette.exceptions.EtiquetteException as e: + response = etiquette.jsonify.exception(e) + response = jsonify.make_json_response(response, status=400) + flask.abort(response) response = etiquette.jsonify.bookmark(bookmark) response = jsonify.make_json_response(response) return response