mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-16 10:12:32 -05:00
Fix how the exception is logged.
This commit is contained in:
@@ -157,17 +157,21 @@ def send_sms(self,
|
|||||||
# Sometimes, SQS plays the same message twice. We should be able to catch an IntegrityError, but it seems
|
# Sometimes, SQS plays the same message twice. We should be able to catch an IntegrityError, but it seems
|
||||||
# SQLAlchemy is throwing a FlushError. So we check if the notification id already exists then do not
|
# SQLAlchemy is throwing a FlushError. So we check if the notification id already exists then do not
|
||||||
# send to the retry queue.
|
# send to the retry queue.
|
||||||
current_app.logger.exception(
|
current_app.logger.error(
|
||||||
"RETRY: send_sms notification for job {} row number {}".format(
|
"RETRY: send_sms notification for job {} row number {} and notification id {}".format(
|
||||||
notification.get('job', None),
|
notification.get('job', None),
|
||||||
notification.get('row_number', None)), e)
|
notification.get('row_number', None),
|
||||||
|
notification_id))
|
||||||
|
current_app.logger.exception(e)
|
||||||
try:
|
try:
|
||||||
raise self.retry(queue="retry", exc=e)
|
raise self.retry(queue="retry", exc=e)
|
||||||
except self.MaxRetriesExceededError:
|
except self.MaxRetriesExceededError:
|
||||||
current_app.logger.exception(
|
current_app.logger.error(
|
||||||
"RETRY FAILED: task send_sms failed for notification".format(
|
"RETRY FAILED: send_sms notification for job {} row number {} and notification id {}".format(
|
||||||
notification.get('job', None),
|
notification.get('job', None),
|
||||||
notification.get('row_number', None)), e)
|
notification.get('row_number', None),
|
||||||
|
notification_id))
|
||||||
|
current_app.logger.exception(e)
|
||||||
|
|
||||||
|
|
||||||
@notify_celery.task(bind=True, name="send-email", max_retries=5, default_retry_delay=300)
|
@notify_celery.task(bind=True, name="send-email", max_retries=5, default_retry_delay=300)
|
||||||
@@ -212,13 +216,18 @@ def send_email(self, service_id,
|
|||||||
# Sometimes, SQS plays the same message twice. We should be able to catch an IntegrityError, but it seems
|
# Sometimes, SQS plays the same message twice. We should be able to catch an IntegrityError, but it seems
|
||||||
# SQLAlchemy is throwing a FlushError. So we check if the notification id already exists then do not
|
# SQLAlchemy is throwing a FlushError. So we check if the notification id already exists then do not
|
||||||
# send to the retry queue.
|
# send to the retry queue.
|
||||||
current_app.logger.exception("RETRY: send_email notification".format(notification.get('job', None),
|
current_app.logger.error(
|
||||||
notification.get('row_number', None)),
|
"RETRY: send_sms notification for job {} row number {} and notification id {}".format(
|
||||||
e)
|
notification.get('job', None),
|
||||||
|
notification.get('row_number', None),
|
||||||
|
notification_id))
|
||||||
|
current_app.logger.exception(e)
|
||||||
try:
|
try:
|
||||||
raise self.retry(queue="retry", exc=e)
|
raise self.retry(queue="retry", exc=e)
|
||||||
except self.MaxRetriesExceededError:
|
except self.MaxRetriesExceededError:
|
||||||
current_app.logger.error(
|
current_app.logger.error(
|
||||||
"RETRY FAILED: task send_email failed for notification".format(
|
"RETRY FAILED: send_sms notification for job {} row number {} and notification id {}".format(
|
||||||
notification.get('job', None),
|
notification.get('job', None),
|
||||||
notification.get('row_number', None)), e)
|
notification.get('row_number', None),
|
||||||
|
notification_id))
|
||||||
|
current_app.logger.exception(e)
|
||||||
|
|||||||
Reference in New Issue
Block a user