Send more jsonified exceptions instead of just 500.

This commit is contained in:
voussoir 2017-06-14 22:48:50 -07:00
parent a7cb922983
commit 1b9f7608b1

View file

@ -491,7 +491,12 @@ def post_album_edit(albumid):
title = request.form.get('title', None)
description = request.form.get('description', None)
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)
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