mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 23:26:23 -05:00
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:
@@ -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']))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user