fix(platform): Capture Sentry Block Errors Correctly (#11404)

Currently we are capturing block errors via the scope only, this change
captures the error directly.

### Changes 🏗️

- capture the error as well as the scope in the executor manager
- Update the block error message to include additional details
- remove the __str__ function from blockerror as it is no longer needed

### Checklist 📋

#### For code changes:
- [x] I have clearly listed my changes in the PR description
- [x] I have made a test plan
- [x] I have tested my changes according to the test plan:
  <!-- Put your test plan here: -->
  - [x] Checked that errors are still captured in dev
This commit is contained in:
Swifty
2025-11-19 12:21:47 +01:00
committed by GitHub
parent 184a73de7d
commit 9438817702
2 changed files with 5 additions and 9 deletions

View File

@@ -252,9 +252,9 @@ async def execute_node(
output_size += len(json.dumps(output_data))
log_metadata.debug("Node produced output", **{output_name: output_data})
yield output_name, output_data
except Exception:
except Exception as ex:
# Capture exception WITH context still set before restoring scope
sentry_sdk.capture_exception(scope=scope)
sentry_sdk.capture_exception(error=ex, scope=scope)
sentry_sdk.flush() # Ensure it's sent before we restore scope
# Re-raise to maintain normal error flow
raise

View File

@@ -5,13 +5,9 @@ class BlockError(Exception):
"""An error occurred during the running of a block"""
def __init__(self, message: str, block_name: str, block_id: str) -> None:
super().__init__(message)
self.message = message
self.block_name = block_name
self.block_id = block_id
def __str__(self):
return f"raised by {self.block_name} with message: {self.message}. block_id: {self.block_id}"
super().__init__(
f"raised by {block_name} with message: {message}. block_id: {block_id}"
)
class BlockInputError(BlockError, ValueError):