Exceptions in event handlers
| Newsgroups | gmane.comp.programming.domain-driven-design |
|---|---|
| Message-ID | <[email protected]> |
How should one handle exceptions in events handlers when doing DDD? As a very simplistic example I want Aggregate2 to react to events raised byAggregate1. However Aggregate2 may throw an exception during the event processing and the system is now in an invalid state. I think I read somewhere that a compensating command should be issued; however, doesn't that lead to scattered compensating command all over the code base? Moreover, Aggregate2 may be in another bounded context and may now it needs to know how to issue a command to another BC to fix its error (which may also fail :D) Is there a practical way to handle errors in event handlers?