Proposal for .pipe()
- forward error emitted from src
to dest
in stream
#6113
Labels
feature request
Issues that request new features to be added to Node.js.
stream
Issues and PRs related to the stream subsystem.
While dealing with a weird uncaughtException, emitted by a stream. It inspires me this idea, maybe
.pipe()
can do one more thing to bind an error listener on thesrc
and emit ( forward ) the error todest
automatically.The benefit is: We can easily handle the error on the destination, and no worry that error might be emitted on somewhere we forgot or have no access to it.
In my case, for testing purpose, I emit error on the query object created by node-mysql, and keep to get
uncaughtException
, I checked all the EventEmitters on the scope, and don't know why it happened. Till the end, I understand, node-mysqlforward
the error from the query object to the stream, and my database api(my another module not written in the current module) pipe that stream to a Transform stream and return that transform stream to me. I forgot the stream is not the stream originally created by node-mysql, and to avoid potential uncaughtException, I decide to add error listener to the original stream.It makes the codes ugly, previously. it is
and now, it becomes
It's just an idea, please feel free to close it, if it is no sense :)
The text was updated successfully, but these errors were encountered: