From e20b68b03967db3aea7cf8c988d934ed933fa589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Nut=CC=A6iu?= Date: Sat, 15 Apr 2017 23:54:01 +0300 Subject: [PATCH] improving api error reporting --- src/views/scoreboard.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/views/scoreboard.py b/src/views/scoreboard.py index d59bb18..8809397 100644 --- a/src/views/scoreboard.py +++ b/src/views/scoreboard.py @@ -32,9 +32,11 @@ def upload(): log = flask.escape(content['log']) score = int(content['score']) except KeyError: # Json doesn't contain the keys we need. - return json.dumps({'success': False}), 400, {'ContentType': 'application/json'} + error = "invalid json keys: gpu, cpu, log, score" + return json.dumps({'error': error,'success': False}), 400, {'ContentType': 'application/json'} except TypeError: # The types from the json object are not correct. - return json.dumps({'success': False}), 400, {'ContentType': 'application/json'} + error = "invalid json object" + return json.dumps({'error': error, 'success': False}), 400, {'ContentType': 'application/json'} entry = Result(gpu=gpu, cpu=cpu, log=log, score=score) db.session.add(entry)