Include connection errors in exception handling
This commit is contained in:
@ -40,7 +40,7 @@ def _start():
|
||||
entry.set_email(request.form.get('email'))
|
||||
code = request.form.get('test_code').replace('—', '').lower()
|
||||
try: test = Test.query.filter_by(code=code).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)
|
||||
entry.test = test
|
||||
@ -69,7 +69,7 @@ def _quiz():
|
||||
flash('Your session was not recognised. Please sign in to the quiz again.', 'error')
|
||||
session.pop('id', None)
|
||||
return redirect(url_for('quiz._start'))
|
||||
except SQLAlchemyError as exception:
|
||||
except (SQLAlchemyError, ConnectionError) as exception:
|
||||
write('system.log', f'Database error when processing request \'{request.url}\': {exception}')
|
||||
return abort(500)
|
||||
return render_template('/quiz/client.html')
|
||||
@ -78,7 +78,7 @@ def _quiz():
|
||||
def _result():
|
||||
id = session.get('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 abort(404)
|
||||
|
Reference in New Issue
Block a user