From 989a34e0e247fead688fbfbd5d0344d8661b1df7 Mon Sep 17 00:00:00 2001 From: Lucas Gameiro Borges Date: Mon, 16 Dec 2024 14:34:24 +0000 Subject: [PATCH] add extra try-catch --- src/backups.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backups.py b/src/backups.py index f661458467..5c4646317d 100644 --- a/src/backups.py +++ b/src/backups.py @@ -18,7 +18,7 @@ import boto3 as boto3 import botocore -from botocore.exceptions import ClientError +from botocore.exceptions import ClientError, ParamValidationError from charms.data_platform_libs.v0.s3 import ( CredentialsChangedEvent, S3Requirer, @@ -290,7 +290,7 @@ def _create_bucket_if_not_exists(self) -> None: bucket.wait_until_exists() logger.info("Created bucket '%s' in region=%s", bucket_name, region) - except ClientError as error: + except (ClientError, ParamValidationError) as error: logger.exception( "Couldn't create bucket named '%s' in region=%s.", bucket_name, region ) @@ -783,7 +783,7 @@ def _on_s3_credential_changed_primary(self, event: HookEvent) -> bool: try: self._create_bucket_if_not_exists() - except (ClientError, ValueError): + except (ClientError, ValueError, ParamValidationError): self._s3_initialization_set_failure(FAILED_TO_ACCESS_CREATE_BUCKET_ERROR_MESSAGE) return False