Is it necessary to explicitly handle Node.js stream errors?

33 Views Asked by At

I'm using the archiver package in order to compress files and upload them via a stream.

It's my first time using streams in Node.js, and in the documentation of archiver I have stumbled upon the following case:

// good practice to catch this error explicitly
archive.on('error', function(err) {
  throw err;
});

In this scenario, is it necessary to listen on error just to throw it? Does it make any difference if I simply omit this step?

If not, why is it considered a good practice by the docs?

0

There are 0 best solutions below