diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2019-04-04 19:21:49 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2019-04-04 19:21:49 -0700 |
commit | b665ea21aea1773735558f2486252b01a79f45b2 (patch) | |
tree | 33cf3713715d9aa6eed3b5df8ca4560bdb9545b6 | |
parent | fc443013d4a004d69c53be3286e33dd30921879e (diff) | |
download | fatcat-b665ea21aea1773735558f2486252b01a79f45b2.tar.gz fatcat-b665ea21aea1773735558f2486252b01a79f45b2.zip |
better error responses for username change form
-rw-r--r-- | python/fatcat_web/routes.py | 10 |
1 files 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) |