improving api error reporting
This commit is contained in:
parent
b7a01e0a7d
commit
e20b68b039
1 changed files with 4 additions and 2 deletions
|
@ -32,9 +32,11 @@ def upload():
|
||||||
log = flask.escape(content['log'])
|
log = flask.escape(content['log'])
|
||||||
score = int(content['score'])
|
score = int(content['score'])
|
||||||
except KeyError: # Json doesn't contain the keys we need.
|
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.
|
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)
|
entry = Result(gpu=gpu, cpu=cpu, log=log, score=score)
|
||||||
db.session.add(entry)
|
db.session.add(entry)
|
||||||
|
|
Loading…
Reference in a new issue