Dealing with It Downstream
Ideally, the operations we perform in the functional pipeline are pure operations with no side-effects. The data flows in harmony as it gets transformed from one stage of the functional pipeline to the next. In reality, things go wrong, Murphy’s law intervenes, and we have to gracefully deal with the messes we may run into.
A good strategy to deal with errors and exceptions in functional programming is to treat an error as a form of data, move it down the pipeline, and deal with it downstream.
Wrap the Exception Received into an Object | |
---|---|
![]() | Treat errors and exceptions as forms of data. Wrap the details in an object and ... |
Get Functional Programming in Java, 2nd Edition 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.