Skip to content

Commit

Permalink
fix: catch ClientError for Cloudwatch repository
Browse files Browse the repository at this point in the history
  • Loading branch information
mutantsan committed Dec 11, 2024
1 parent fc122db commit ef8fc3c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions ckanext/event_audit/repositories/cloudwatch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import logging
import json
from contextlib import suppress
from datetime import datetime, timezone
Expand All @@ -19,6 +20,9 @@
from ckanext.event_audit.repositories.base import AbstractRepository, RemoveAll


log = logging.getLogger(__name__)


class CloudWatchEvent(TypedDict):
timestamp: int
message: str
Expand Down Expand Up @@ -103,7 +107,9 @@ def write_event(self, event: types.Event) -> types.Result:
self.client.exceptions.ResourceNotFoundException,
self.client.exceptions.ServiceUnavailableException,
self.client.exceptions.UnrecognizedClientException,
self.client.exceptions.ClientError,
) as e:
log.error(f"Failed to write event to CloudWatch: {e}")
return types.Result(status=False, message=str(e))

def _create_log_stream_if_not_exists(self, log_stream: str) -> str:
Expand Down Expand Up @@ -227,6 +233,7 @@ def remove_all_events(self) -> types.Result:
try:
self.client.delete_log_group(logGroupName=self.log_group)
except self.client.exceptions.ResourceNotFoundException as err:
log.error(f"Failed to remove all events from CloudWatch: {err}")
return types.Result(status=False, message=str(err))

return types.Result(status=True, message="All events removed successfully")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "ckanext-event-audit"
version = "1.1.0"
version = "1.1.1"
description = ""
classifiers = [
"Development Status :: 4 - Beta",
Expand Down

0 comments on commit ef8fc3c

Please sign in to comment.