-
Notifications
You must be signed in to change notification settings - Fork 0
CheckedException
Ben Christel edited this page Jan 14, 2022
·
2 revisions
Checked exceptions (e.g. in Java) should be avoided. Too often, they force domain code to know about infrastructural errors—errors that ought to be handled by the ImperativeShell. This impedes ContractTesting because the domain code's collaborators often cannot implement UbiquitousInterfaces if they have to declare that they throw an exception.
When errors or exceptional cases exist in the domain, they're better represented by AlgebraicTypes like Maybe or Either. These types of errors cannot be handled by the ImperativeShell—they have to be handled in domain code—so it's nice if the type system forces you to handle them.