Adapting Other Kinds of Functions to the Two-Track Model
So far, we have seen two function “shapes” in our pipeline: one-track functions and “switch” functions. But of course we may need to work with many other kinds of functions. Let’s look at two of them now:
- Functions that throw exceptions
- “Dead-end” functions that don’t return anything
Handling Exceptions
We’ve avoided throwing exceptions in our code, but what about exceptions that are raised in code not controlled by us, such as in a library or service. Earlier, we suggested that many exceptions are not part of the domain design and need not be caught except at the top level. But if we do want to treat an exception as part of the domain, how should we do that?
The solution is straightforward—we ...
Get Domain Modeling Made Functional now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.