mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-10 18:22:37 -04:00
This repeats the pattern we already have for previewing a letter, where we assume the error is because the notification has already been sent and redirect the user to see it. I've improved the original pattern a bit: - I've DRYed-up the low-level boto code and moved the error handler there so it can be reused. - I've introduced a custom exception, which the calling code can choose to log. - I've introduced the moto library, which we use elsewhere, to make it easier to test S3 code. I've used an error level log when sending a notification - now that we have a more descriptive log, we can verify the assumption is true and then make an informed decision to downgrade the log. In future we may want to merge this handler with the similar code in utils [1], but we'll need to be careful as the utils handler is superficial - it doesn't check the reason for the error. [1]: https://github.com/alphagov/notifications-utils/blob/bce0f4e596af9451212d0026c8ecc27b636eed38/notifications_utils/s3.py#L52