stream: make virtual methods errors consistent

Use the same error code and always emit the error instead of
throwing it.

PR-URL: https://github.com/nodejs/node/pull/18813
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaë Zasso <targos@protonmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
Luigi Pinca 2018-02-16 12:53:34 +01:00
parent 8403f00dc3
commit c9794880e8
9 changed files with 58 additions and 61 deletions

View file

@ -162,7 +162,7 @@ Transform.prototype.push = function(chunk, encoding) {
// an error, then that'll put the hurt on the whole operation. If you
// never call cb(), then you'll never get another chunk.
Transform.prototype._transform = function(chunk, encoding, cb) {
throw new ERR_METHOD_NOT_IMPLEMENTED('_transform');
cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()'));
};
Transform.prototype._write = function(chunk, encoding, cb) {