Don't re-raise exceptions that are 'handled in the UI'

we now have handling for them, no need to keep seeing them as stacktraces.
also: in the EAGER setup, raising means the transaciton is rolled back,
and nothing is stored in the DB at all.

if we ever want to 'get more info' something like capture_or_log_exception
would be more apt
This commit is contained in:
Klaas van Schelven
2025-07-28 21:55:59 +02:00
parent fe343f0749
commit 0aa7de30d2
2 changed files with 20 additions and 27 deletions

View File

@@ -131,11 +131,9 @@ def slack_backend_send_test_message(webhook_url, project_name, display_name, ser
except requests.RequestException as e:
response = getattr(e, 'response', None)
_store_failure_info(service_config_id, e, response)
raise
except Exception as e:
_store_failure_info(service_config_id, e)
raise
@shared_task
@@ -211,11 +209,9 @@ def slack_backend_send_alert(
except requests.RequestException as e:
response = getattr(e, 'response', None)
_store_failure_info(service_config_id, e, response)
raise
except Exception as e:
_store_failure_info(service_config_id, e)
raise
class SlackBackend:

View File

@@ -192,14 +192,13 @@ class TestSlackBackendErrorHandling(DjangoTestCase):
mock_post.return_value = mock_response
# Send test message and expect it to raise
with self.assertRaises(requests.HTTPError):
slack_backend_send_test_message(
"https://hooks.slack.com/test",
"Test project",
"Test Slack",
self.config.id
)
# Send test message
slack_backend_send_test_message(
"https://hooks.slack.com/test",
"Test project",
"Test Slack",
self.config.id
)
# Verify failure status was stored
self.config.refresh_from_db()
@@ -224,13 +223,12 @@ class TestSlackBackendErrorHandling(DjangoTestCase):
mock_post.return_value = mock_response
# Send test message and expect it to raise
with self.assertRaises(requests.HTTPError):
slack_backend_send_test_message(
"https://hooks.slack.com/test",
"Test project",
"Test Slack",
self.config.id
)
slack_backend_send_test_message(
"https://hooks.slack.com/test",
"Test project",
"Test Slack",
self.config.id
)
# Verify failure status was stored
self.config.refresh_from_db()
@@ -244,14 +242,13 @@ class TestSlackBackendErrorHandling(DjangoTestCase):
# Mock connection error
mock_post.side_effect = requests.ConnectionError("Connection failed")
# Send test message and expect it to raise
with self.assertRaises(requests.ConnectionError):
slack_backend_send_test_message(
"https://hooks.slack.com/test",
"Test project",
"Test Slack",
self.config.id
)
# Send test message
slack_backend_send_test_message(
"https://hooks.slack.com/test",
"Test project",
"Test Slack",
self.config.id
)
# Verify failure status was stored
self.config.refresh_from_db()