Permalink
Browse files

errors,stream-transform: migrate to use internal/errors.js

PR-URL: #13310
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
  • Loading branch information...
sreepurnajasti authored and mhdawson committed May 30, 2017
1 parent 3c506af commit d50a802feb0b061383400e3f290ddc7410cb3a48
Showing with 11 additions and 6 deletions.
  1. +4 −5 lib/_stream_transform.js
  2. +5 −0 lib/internal/errors.js
  3. +2 −1 test/parallel/test-stream-transform-callback-twice.js
View
@@ -64,7 +64,7 @@
'use strict';
module.exports = Transform;
const errors = require('internal/errors');
const Duplex = require('_stream_duplex');
const util = require('util');
util.inherits(Transform, Duplex);
@@ -78,7 +78,7 @@ function afterTransform(er, data) {
if (!cb) {
return this.emit('error',
new Error('write callback called multiple times'));
new errors.Error('ERR_TRANSFORM_MULTIPLE_CALLBACK'));
}
ts.writechunk = null;
@@ -210,10 +210,9 @@ function done(stream, er, data) {
// if there's nothing in the write buffer, then that means
// that nothing more will ever be provided
if (stream._writableState.length)
throw new Error('Calling transform done when ws.length != 0');
throw new errors.Error('ERR_TRANSFORM_WITH_LENGTH_0');
if (stream._transformState.transforming)
throw new Error('Calling transform done when still transforming');
throw new errors.Error('ERR_TRANSFORM_ALREADY_TRANSFORMING');
return stream.push(null);
}
View
@@ -157,6 +157,11 @@ E('ERR_PARSE_HISTORY_DATA',
(oldHistoryPath) => `Could not parse history data in ${oldHistoryPath}`);
E('ERR_STDERR_CLOSE', 'process.stderr cannot be closed');
E('ERR_STDOUT_CLOSE', 'process.stdout cannot be closed');
E('ERR_TRANSFORM_ALREADY_TRANSFORMING',
'Calling transform done when still transforming');
E('ERR_TRANSFORM_MULTIPLE_CALLBACK', 'Callback called multiple times');
E('ERR_TRANSFORM_WITH_LENGTH_0',
'Calling transform done when ws.length != 0');
E('ERR_HTTP_TRAILER_INVALID',
'Trailers are invalid with this transfer encoding');
E('ERR_UNKNOWN_BUILTIN_MODULE', (id) => `No such built-in module: ${id}`);
@@ -8,7 +8,8 @@ const stream = new Transform({
stream.on('error', common.mustCall((err) => {
assert.strictEqual(err.toString(),
'Error: write callback called multiple times');
'Error [ERR_TRANSFORM_MULTIPLE_CALLBACK]: ' +
'Callback called multiple times');
}));
stream.write('foo');

0 comments on commit d50a802

Please sign in to comment.