Include connection errors in exception handling
This commit is contained in:
@ -20,7 +20,7 @@ api = Blueprint(
|
||||
def _fetch_questions():
|
||||
id = request.get_json()['id']
|
||||
try: entry = Entry.query.filter_by(id=id).first()
|
||||
except SQLAlchemyError as exception:
|
||||
except (SQLAlchemyError, ConnectionError) as exception:
|
||||
write('system.log', f'Database error when processing request \'{request.url}\': {exception}')
|
||||
return abort(500)
|
||||
if not entry: return jsonify({'error': 'Invalid entry ID.'}), 400
|
||||
@ -57,7 +57,7 @@ def _submit_quiz():
|
||||
id = request.get_json()['id']
|
||||
answers = request.get_json()['answers']
|
||||
try: entry = Entry.query.filter_by(id=id).first()
|
||||
except SQLAlchemyError as exception:
|
||||
except (SQLAlchemyError, ConnectionError) as exception:
|
||||
write('system.log', f'Database error when processing request \'{request.url}\': {exception}')
|
||||
return abort(500)
|
||||
if not entry: return jsonify({'error': 'Unrecognised Entry.'}), 400
|
||||
|
Reference in New Issue
Block a user