From b665ea21aea1773735558f2486252b01a79f45b2 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 4 Apr 2019 19:21:49 -0700 Subject: better error responses for username change form --- python/fatcat_web/routes.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py index 18c51d43..3479a937 100644 --- a/python/fatcat_web/routes.py +++ b/python/fatcat_web/routes.py @@ -629,9 +629,13 @@ def change_username(): abort(400) # on behalf of user... user_api = auth_api(session['api_token']) - editor = user_api.get_editor(session['editor']['editor_id']) - editor.username = request.form['username'] - editor = user_api.update_editor(editor.editor_id, editor) + try: + editor = user_api.get_editor(session['editor']['editor_id']) + editor.username = request.form['username'] + editor = user_api.update_editor(editor.editor_id, editor) + except ApiException as ae: + app.log.info(ae) + abort(ae.status) # update our session session['editor'] = editor.to_dict() load_user(editor.editor_id) -- cgit v1.2.3