DEV Community

Discussion on: Tricks on writing & appending to a file in Node.js

Collapse
shivams136 profile image
Shivam Sharma

How to handle file open/write errors in stream?

Collapse
sergchr profile image
Sergiy Author

Streams have on('error', handler) method to handle potential errors. E.g.

stream.on('error', (e) => console.log('I got an error!', e));
Enter fullscreen mode Exit fullscreen mode
Collapse
shivams136 profile image
Shivam Sharma

Ok, thanks