...

/

Better Error Handling with pipeline()

Better Error Handling with pipeline()

Learn how to handle errors using the pipeline() helper function.

We'll cover the following...

Handling errors manually in a pipeline is not just cumbersome, but also error prone—definitely something we should avoid if we can!

Luckily, the core stream package offers us an excellent utility function that can make building pipelines a much safer and more enjoyable practice, which is the pipeline() helper function.

The syntax for the pipeline() function is as follows:

pipeline(stream1, stream2, stream3, ... , cb)

This helper pipes every stream passed in the arguments list to the next one. For each stream, it’ll also register a proper error and close listeners. This way, all the streams are ...