Skip to content

Error handling in Query trait implementations #33

Answered by davegarred
johnbcodes asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @johnbcodes.

The reason that queries are infallible in the framework is that in CQRS the command handler work on the aggregate is always considered the sole source of truth. Any logic that could cause the command to fail should be inside the aggregate. Without that separation of aggregate logic and query updates we would lose a lot of the benefits that CQRS provides us (API decoupling, horizontal scaling, state error debugging, etc.).

Application of events to queries can absolutely fail IRL. In CQRS though you need to find other ways to deal with it. Many times this will be putting the view in question into some sort of an error state (e.g., add a flag to show the customer that "someth…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by davegarred
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants