How can you handle errors in a readable stream in Node.js?

  • stream.on('error', (err) => { /* Handle error */ });
  • stream.catch((err) => { /* Handle error */ });
  • stream.error((err) => { /* Handle error */ });
  • try { /* Stream operations */ } catch (err) { /* Handle error */ }
In Node.js, you can handle errors in a readable stream by listening to the 'error' event using stream.on('error', (err) => { /* Handle error */ });. The other options are not the correct way to handle errors in streams.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *