errors,stream-transform: migrate to use internal/errors.js
PR-URL: https://github.com/nodejs/node/pull/13310 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
This commit is contained in:
parent
3c506af78b
commit
d50a802feb
@ -64,7 +64,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
module.exports = Transform;
|
module.exports = Transform;
|
||||||
|
const errors = require('internal/errors');
|
||||||
const Duplex = require('_stream_duplex');
|
const Duplex = require('_stream_duplex');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
util.inherits(Transform, Duplex);
|
util.inherits(Transform, Duplex);
|
||||||
@ -78,7 +78,7 @@ function afterTransform(er, data) {
|
|||||||
|
|
||||||
if (!cb) {
|
if (!cb) {
|
||||||
return this.emit('error',
|
return this.emit('error',
|
||||||
new Error('write callback called multiple times'));
|
new errors.Error('ERR_TRANSFORM_MULTIPLE_CALLBACK'));
|
||||||
}
|
}
|
||||||
|
|
||||||
ts.writechunk = null;
|
ts.writechunk = null;
|
||||||
@ -210,10 +210,9 @@ function done(stream, er, data) {
|
|||||||
// if there's nothing in the write buffer, then that means
|
// if there's nothing in the write buffer, then that means
|
||||||
// that nothing more will ever be provided
|
// that nothing more will ever be provided
|
||||||
if (stream._writableState.length)
|
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)
|
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);
|
return stream.push(null);
|
||||||
}
|
}
|
||||||
|
@ -157,6 +157,11 @@ E('ERR_PARSE_HISTORY_DATA',
|
|||||||
(oldHistoryPath) => `Could not parse history data in ${oldHistoryPath}`);
|
(oldHistoryPath) => `Could not parse history data in ${oldHistoryPath}`);
|
||||||
E('ERR_STDERR_CLOSE', 'process.stderr cannot be closed');
|
E('ERR_STDERR_CLOSE', 'process.stderr cannot be closed');
|
||||||
E('ERR_STDOUT_CLOSE', 'process.stdout 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',
|
E('ERR_HTTP_TRAILER_INVALID',
|
||||||
'Trailers are invalid with this transfer encoding');
|
'Trailers are invalid with this transfer encoding');
|
||||||
E('ERR_UNKNOWN_BUILTIN_MODULE', (id) => `No such built-in module: ${id}`);
|
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) => {
|
stream.on('error', common.mustCall((err) => {
|
||||||
assert.strictEqual(err.toString(),
|
assert.strictEqual(err.toString(),
|
||||||
'Error: write callback called multiple times');
|
'Error [ERR_TRANSFORM_MULTIPLE_CALLBACK]: ' +
|
||||||
|
'Callback called multiple times');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
stream.write('foo');
|
stream.write('foo');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user