Skip to content

Commit

Permalink
fix: capture slack errors without throwing
Browse files Browse the repository at this point in the history
  • Loading branch information
Justintime50 committed May 1, 2024
1 parent a218823 commit 9a96856
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Adds a healthcheck to the nginx Docker container
- Prints deployment log to the error logger if `log_level` is set to `DEBUG`
- Raises a `HarveyError` on deployment fail instead of `sys.exit(1)`, removes redundant `sys.exit(0)` on success
- Captures Slack errors via Sentry but no longer raises an exception to ensure builds continue even if there is a problem with message delivery

## v1.0.3 (2023-10-25)

Expand Down
8 changes: 4 additions & 4 deletions harvey/messages.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import slack_sdk
import woodchips
from sentry_sdk import capture_exception

from harvey.config import Config
from harvey.errors import HarveyError


class Message:
Expand All @@ -23,7 +23,7 @@ def send_slack_message(message: str):
text=message,
)
logger.debug('Slack message sent!')
except slack_sdk.errors.SlackApiError:
error_message = 'Harvey could not send the Slack message.'
except slack_sdk.errors.SlackApiError as error:
error_message = f'Harvey could not send the Slack message: {error}'
logger.error(error_message)
raise HarveyError(error_message)
capture_exception(error_message)

0 comments on commit 9a96856

Please sign in to comment.