July 2023
Intermediate to advanced
276 pages
6h 55m
English
When programming with the functional style and the Stream API, treat errors as forms of data. If a lower-level function called in one of the stages of the pipeline throws an exception, capture and wrap that into a failure object. Instead of writing your pipeline so that it moves only data, design it to move a union object that may carry either data or an error. This is a good way to deal with errors in a functional pipeline, but there are consequences to this approach.
If none of the stages in a functional pipeline may have errors, then the functions can nicely focus on dealing with data. But, if errors are possible in any stage of the pipeline, then the stages downstream have to be written to work ...
Read now
Unlock full access