Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions bubus/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,17 @@ async def event_results_filtered(

if raise_if_any and error_results:
failing_handler, failing_result = list(error_results.items())[0] # throw first error
raise Exception(
f'Event handler {failing_handler}({self}) returned an error -> {failing_result.error or cast(Any, failing_result.result)}'
)
original_error = failing_result.error or cast(Any, failing_result.result)

# Log the handler context information instead of wrapping the exception
logger.debug(f'Event handler {failing_handler}({self}) returned an error -> {original_error}')

# Re-raise the original exception to preserve its type and structured data
if isinstance(original_error, BaseException):
raise original_error
else:
# Fallback for non-exception errors (shouldn't happen in practice)
raise Exception(str(original_error))

if raise_if_none and not included_results:
raise ValueError(
Expand Down
Loading