Skip to content

Commit

Permalink
add extra try-catch
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasgameiroborges committed Dec 16, 2024
1 parent 5c8949f commit 989a34e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 989a34e

Please sign in to comment.