From 3dcac188497e3c9553d0a5fd4dc50b293a4f2e16 Mon Sep 17 00:00:00 2001 From: David McDonald Date: Wed, 12 Feb 2020 15:28:46 +0000 Subject: [PATCH] Use correct exception for boto3 We use boto3 for our interaction with s3. Therefore if an expection is thrown it will be thrown from the botocore library (which boto3 is built on top of). I have copied app/aws/s3.py::file_exists for an example of this exception catching. --- app/dao/notifications_dao.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/dao/notifications_dao.py b/app/dao/notifications_dao.py index b1a3fa2fb..5aa8d72a1 100644 --- a/app/dao/notifications_dao.py +++ b/app/dao/notifications_dao.py @@ -6,7 +6,7 @@ from datetime import ( timedelta, ) -from boto.exception import BotoClientError +from botocore.exceptions import ClientError from flask import current_app from notifications_utils.international_billing_rates import INTERNATIONAL_BILLING_RATES from notifications_utils.recipients import ( @@ -438,7 +438,7 @@ def _delete_letters_from_s3( for s3_object in s3_objects: try: remove_s3_object(bucket_name, s3_object['Key']) - except BotoClientError: + except ClientError: current_app.logger.exception( "Could not delete S3 object with filename: {}".format(s3_object['Key']))