[Question] DomainExceptions don't bubble up when called through IdentifiedHandler
Hi,
I am working through domain validations and handling of Domain Exceptions. If i'm not mistaken Domain Exceptions do not bubble up when the Domain Exception has been created from a call through IdentifiedCommandHandler. This appears to be due to exceptions being caught but no re thrown in the IdentifiedCommandHandler.cs :
catch { return default(R); }
Is this the intended behavior?
Many thanks.
Hi @benbuckland, thank you for reaching out.
Any command handler class just focuses on processing the command. It doesn't focus on any domain-specific logic because it still stays within the Domain Model/Aggregated root. You may want to include all the domain validation logic in the constructor of the Domain Entity itself. For more details, refer to Design validations in the domain model layer
Hi @sughosneo , thanks for coming back to me. Sorry my questions may not have been clear. My expectation is that any DomainExceptions will eventually bubble back to the caller (and returned through the API) but I'm not seeing that. The line of code I mentioned seems to be suppressing the exceptions from bubbling up or have I missed something?
Hi @sughosneo any update on this? I have had a look at it again today and still cant figure it out.