Generalise exception handling
This commit is contained in:
@ -15,7 +15,7 @@ def require_account_creation(function):
|
||||
if User.query.count() == 0:
|
||||
flash('Please register a user account.', 'alert')
|
||||
return redirect(url_for('admin._register'))
|
||||
except (SQLAlchemyError, ConnectionError) as exception:
|
||||
except Exception as exception:
|
||||
write('system.log', f'Database error when checking for existing accounts: {exception}')
|
||||
return abort(500)
|
||||
return function(*args, **kwargs)
|
||||
|
@ -78,7 +78,7 @@ def check_dataset_exists(function):
|
||||
@wraps(function)
|
||||
def wrapper(*args, **kwargs):
|
||||
try: datasets = Dataset.query.all()
|
||||
except (SQLAlchemyError, ConnectionError) as exception:
|
||||
except Exception as exception:
|
||||
write('system.log', f'Database error when checking existing datasets: {exception}')
|
||||
return abort(500)
|
||||
if not datasets:
|
||||
|
@ -32,7 +32,7 @@ def get_time_options():
|
||||
def get_dataset_choices():
|
||||
from ..models import Dataset
|
||||
try: datasets = Dataset.query.all()
|
||||
except (SQLAlchemyError, ConnectionError) as exception:
|
||||
except Exception as exception:
|
||||
write('system.log', f'Database error when fetching dataset lists: {exception}')
|
||||
return []
|
||||
dataset_choices = []
|
||||
|
@ -133,7 +133,7 @@ def redirect_if_started(function):
|
||||
id = session.get('id')
|
||||
try:
|
||||
if request.method == 'GET' and id and Entry.query.filter_by(id=id).first(): return redirect(url_for('quiz._quiz'))
|
||||
except (SQLAlchemyError, ConnectionError) as exception:
|
||||
except Exception as exception:
|
||||
write('system.log', f'Database error when checking if test has been started: {exception}')
|
||||
return abort(500)
|
||||
return function(*args, **kwargs)
|
||||
|
Reference in New Issue
Block a user