Handler Errors¶
-
Back to Testing Overview
Return to the Testing overview page with all topics.
send returns the command result. The error is on handler_errors.
See Runtime Processing.
class AuditHandler(cqrs.EventHandler[OrderCreated]):
async def handle(self, event: OrderCreated) -> None:
raise RuntimeError("audit failed")
async def test_domain_handler_error_is_swallowed() -> None:
container = di.Container()
async with test_harness(
container,
commands_mapper=commands_mapper,
domain_events_mapper=domain_events_mapper,
) as harness:
result = await harness.mediator.send(CreateOrder(sku="book"))
assert result.order_id == "1"
assert harness.handler_errors.of(OrderCreated, AuditHandler)
Library example: examples/testing/test_domain_and_notification.py.