O'Reilly logo

Domain Modeling Made Functional by Scott Wlaschin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required