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.
This commit is contained in:
David McDonald
2020-02-12 15:28:46 +00:00
parent 755c47c0c1
commit 3dcac18849

View File

@@ -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']))