mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-12 08:12:27 -05:00
downgrade lots of routine logging from error/exception to info
most of them are 400s for badly inputted phone numbers etc
This commit is contained in:
@@ -234,7 +234,6 @@ def init_app(app):
|
||||
@app.errorhandler(404)
|
||||
def page_not_found(e):
|
||||
msg = e.description or "Not found"
|
||||
app.logger.exception(msg)
|
||||
return jsonify(result='error', message=msg), 404
|
||||
|
||||
|
||||
|
||||
@@ -53,19 +53,19 @@ def register_errors(blueprint):
|
||||
|
||||
@blueprint.errorhandler(ValidationError)
|
||||
def marshmallow_validation_error(error):
|
||||
current_app.logger.error(error)
|
||||
current_app.logger.info(error)
|
||||
return jsonify(result='error', message=error.messages), 400
|
||||
|
||||
@blueprint.errorhandler(JsonSchemaValidationError)
|
||||
def jsonschema_validation_error(error):
|
||||
current_app.logger.exception(error)
|
||||
current_app.logger.info(error)
|
||||
return jsonify(json.loads(error.message)), 400
|
||||
|
||||
@blueprint.errorhandler(InvalidRequest)
|
||||
def invalid_data(error):
|
||||
response = jsonify(error.to_dict())
|
||||
response.status_code = error.status_code
|
||||
current_app.logger.error(error)
|
||||
current_app.logger.info(error)
|
||||
return response
|
||||
|
||||
@blueprint.errorhandler(400)
|
||||
@@ -92,12 +92,11 @@ def register_errors(blueprint):
|
||||
@blueprint.errorhandler(NoResultFound)
|
||||
@blueprint.errorhandler(DataError)
|
||||
def no_result_found(e):
|
||||
current_app.logger.exception(e)
|
||||
current_app.logger.info(e)
|
||||
return jsonify(result='error', message="No result found"), 404
|
||||
|
||||
@blueprint.errorhandler(SQLAlchemyError)
|
||||
def db_error(e):
|
||||
current_app.logger.exception(e)
|
||||
if hasattr(e, 'orig') and hasattr(e.orig, 'pgerror') and e.orig.pgerror and \
|
||||
('duplicate key value violates unique constraint "services_name_key"' in e.orig.pgerror or
|
||||
'duplicate key value violates unique constraint "services_email_from_key"' in e.orig.pgerror):
|
||||
@@ -107,6 +106,7 @@ def register_errors(blueprint):
|
||||
e.params.get('name', e.params.get('email_from', ''))
|
||||
)]}
|
||||
), 400
|
||||
current_app.logger.exception(e)
|
||||
return jsonify(result='error', message="Internal server error"), 500
|
||||
|
||||
# this must be defined after all other error handlers since it catches the generic Exception object
|
||||
|
||||
@@ -62,19 +62,19 @@ def register_errors(blueprint):
|
||||
def invalid_format(error):
|
||||
# Please not that InvalidEmailError is re-raised for InvalidEmail or InvalidPhone,
|
||||
# work should be done in the utils app to tidy up these errors.
|
||||
current_app.logger.exception(error)
|
||||
current_app.logger.info(error)
|
||||
return jsonify(status_code=400,
|
||||
errors=[{"error": error.__class__.__name__, "message": str(error)}]), 400
|
||||
|
||||
@blueprint.errorhandler(InvalidRequest)
|
||||
def invalid_data(error):
|
||||
current_app.logger.error(error)
|
||||
current_app.logger.info(error)
|
||||
response = jsonify(error.to_dict_v2()), error.status_code
|
||||
return response
|
||||
|
||||
@blueprint.errorhandler(ValidationError)
|
||||
def validation_error(error):
|
||||
current_app.logger.exception(error)
|
||||
current_app.logger.info(error)
|
||||
return jsonify(json.loads(error.message)), 400
|
||||
|
||||
@blueprint.errorhandler(JobIncompleteError)
|
||||
@@ -84,7 +84,7 @@ def register_errors(blueprint):
|
||||
@blueprint.errorhandler(NoResultFound)
|
||||
@blueprint.errorhandler(DataError)
|
||||
def no_result_found(e):
|
||||
current_app.logger.exception(e)
|
||||
current_app.logger.info(e)
|
||||
return jsonify(status_code=404,
|
||||
errors=[{"error": e.__class__.__name__, "message": "No result found"}]), 404
|
||||
|
||||
|
||||
Reference in New Issue
Block a user