Changed db queries to use one, which throws NoResultFound exception, this exception is dealt with in our error handlers.

Now a lot of the if none checks can be removed.
This commit is contained in:
Rebecca Law
2016-03-11 12:39:55 +00:00
parent 209244ff19
commit e055590b07
19 changed files with 66 additions and 112 deletions

View File

@@ -48,15 +48,15 @@ def register_errors(blueprint):
@blueprint.app_errorhandler(NoResultFound)
def no_result_found(e):
current_app.logger.error(e)
current_app.logger.error(str(e))
return jsonify(result='error', message="No result found"), 404
@blueprint.app_errorhandler(DataError)
def data_error(e):
current_app.logger.error(e)
current_app.logger.error(str(e))
return jsonify(result='error', message="No result found"), 404
@blueprint.app_errorhandler(SQLAlchemyError)
def db_error(e):
current_app.logger.error(e)
current_app.logger.error(str(e))
return jsonify(result='error', message=str(e)), 500