| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent de61f97 commit 88fb359
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1317,6 +1317,24 @@ Node.js does not allow `stdout` or `stderr` Streams to be closed by user code. | |||
| 1317 | 1317 | Used when an attempt is made to close the `process.stdout` stream. By design, | |
| 1318 | 1318 | Node.js does not allow `stdout` or `stderr` Streams to be closed by user code. | |
| 1319 | 1319 | ||
| 1320 | + <a id="ERR_STREAM_PUSH_AFTER_EOF"></a> | ||
| 1321 | + ### ERR_STREAM_PUSH_AFTER_EOF | ||
| 1322 | + | ||
| 1323 | + Used when an attempt is made to call [`stream.push()`][] after a `null`(EOF) | ||
| 1324 | + has been pushed to the stream. | ||
| 1325 | + | ||
| 1326 | + <a id="ERR_STREAM_READ_NOT_IMPLEMENTED"></a> | ||
| 1327 | + ### ERR_STREAM_READ_NOT_IMPLEMENTED | ||
| 1328 | + | ||
| 1329 | + Used when an attempt is made to use a readable stream that has not implemented | ||
| 1330 | + [`readable._read()`][]. | ||
| 1331 | + | ||
| 1332 | + <a id="ERR_STREAM_UNSHIFT_AFTER_END_EVENT"></a> | ||
| 1333 | + ### ERR_STREAM_UNSHIFT_AFTER_END_EVENT | ||
| 1334 | + | ||
| 1335 | + Used when an attempt is made to call [`stream.unshift()`][] after the | ||
| 1336 | + `end` event has been emitted. | ||
| 1337 | + | ||
| 1320 | 1338 | <a id="ERR_STREAM_WRAP"></a> | |
| 1321 | 1339 | ### ERR_STREAM_WRAP | |
| 1322 | 1340 | ||
@@ -1462,7 +1480,10 @@ closed. | |||
| 1462 | 1480 | [`ERR_INVALID_ARG_TYPE`]: #ERR_INVALID_ARG_TYPE | |
| 1463 | 1481 | [`hash.digest()`]: crypto.html#crypto_hash_digest_encoding | |
| 1464 | 1482 | [`hash.update()`]: crypto.html#crypto_hash_update_data_inputencoding | |
| 1483 | + [`readable._read()`]: stream.html#stream_readable_read_size_1 | ||
| 1465 | 1484 | [`sign.sign()`]: crypto.html#crypto_sign_sign_privatekey_outputformat | |
| 1485 | + [`stream.push()`]: stream.html#stream_readable_push_chunk_encoding | ||
| 1486 | + [`stream.unshift()`]: stream.html#stream_readable_unshift_chunk | ||
| 1466 | 1487 | [`subprocess.kill()`]: child_process.html#child_process_subprocess_kill_signal | |
| 1467 | 1488 | [`subprocess.send()`]: child_process.html#child_process_subprocess_send_message_sendhandle_options_callback | |
| 1468 | 1489 | [`fs.readFileSync`]: fs.html#fs_fs_readfilesync_path_options | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,6 +31,7 @@ const util = require('util'); | |||
| 31 | 31 | const debug = util.debuglog('stream'); | |
| 32 | 32 | const BufferList = require('internal/streams/BufferList'); | |
| 33 | 33 | const destroyImpl = require('internal/streams/destroy'); | |
| 34 | + const errors = require('internal/errors'); | ||
| 34 | 35 | var StringDecoder; | |
| 35 | 36 | ||
| 36 | 37 | util.inherits(Readable, Stream); | |
@@ -233,11 +234,12 @@ function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { | |||
| 233 | 234 | ||
| 234 | 235 | if (addToFront) { | |
| 235 | 236 | if (state.endEmitted) | |
| 236 | - stream.emit('error', new Error('stream.unshift() after end event')); | ||
| 237 | + stream.emit('error', | ||
| 238 | + new errors.Error('ERR_STREAM_UNSHIFT_AFTER_END_EVENT')); | ||
| 237 | 239 | else | |
| 238 | 240 | addChunk(stream, state, chunk, true); | |
| 239 | 241 | } else if (state.ended) { | |
| 240 | - stream.emit('error', new Error('stream.push() after EOF')); | ||
| 242 | + stream.emit('error', new errors.Error('ERR_STREAM_PUSH_AFTER_EOF')); | ||
| 241 | 243 | } else { | |
| 242 | 244 | state.reading = false; | |
| 243 | 245 | if (state.decoder && !encoding) { | |
@@ -548,7 +550,7 @@ function maybeReadMore_(stream, state) { | |||
| 548 | 550 | // for virtual (non-string, non-buffer) streams, "length" is somewhat | |
| 549 | 551 | // arbitrary, and perhaps not very meaningful. | |
| 550 | 552 | Readable.prototype._read = function(n) { | |
| 551 | - this.emit('error', new Error('_read() is not implemented')); | ||
| 553 | + this.emit('error', new errors.Error('ERR_STREAM_READ_NOT_IMPLEMENTED')); | ||
| 552 | 554 | }; | |
| 553 | 555 | ||
| 554 | 556 | Readable.prototype.pipe = function(dest, pipeOpts) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -325,6 +325,9 @@ E('ERR_SOCKET_CLOSED', 'Socket is closed'); | |||
| 325 | 325 | E('ERR_SOCKET_DGRAM_NOT_RUNNING', 'Not running'); | |
| 326 | 326 | E('ERR_STDERR_CLOSE', 'process.stderr cannot be closed'); | |
| 327 | 327 | E('ERR_STDOUT_CLOSE', 'process.stdout cannot be closed'); | |
| 328 | + E('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF'); | ||
| 329 | + E('ERR_STREAM_READ_NOT_IMPLEMENTED', '_read() is not implemented'); | ||
| 330 | + E('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event'); | ||
| 328 | 331 | E('ERR_STREAM_WRAP', 'Stream has StringDecoder set or is in objectMode'); | |
| 329 | 332 | E('ERR_TLS_CERT_ALTNAME_INVALID', | |
| 330 | 333 | 'Hostname/IP does not match certificate\'s altnames: %s'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,8 +1,12 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - require('../common'); | ||
| 2 | + const common = require('../common'); | ||
| 3 | 3 | const stream = require('stream'); | |
| 4 | 4 | const assert = require('assert'); | |
| 5 | 5 | ||
| 6 | 6 | const readable = new stream.Readable(); | |
| 7 | 7 | ||
| 8 | - assert.throws(() => readable.read(), /not implemented/); | ||
| 8 | + assert.throws(() => readable.read(), common.expectsError({ | ||
| 9 | + code: 'ERR_STREAM_READ_NOT_IMPLEMENTED', | ||
| 10 | + type: Error, | ||
| 11 | + message: '_read() is not implemented' | ||
| 12 | + })); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -70,7 +70,11 @@ r._read = function(n) { | |||
| 70 | 70 | function pushError() { | |
| 71 | 71 | assert.throws(function() { | |
| 72 | 72 | r.push(Buffer.allocUnsafe(1)); | |
| 73 | - }, /^Error: stream\.push\(\) after EOF$/); | ||
| 73 | + }, common.expectsError({ | ||
| 74 | + code: 'ERR_STREAM_PUSH_AFTER_EOF', | ||
| 75 | + type: Error, | ||
| 76 | + message: 'stream.push() after EOF' | ||
| 77 | + })); | ||
| 74 | 78 | } | |
| 75 | 79 | ||
| 76 | 80 | ||
@@ -84,7 +88,11 @@ w._write = function(chunk, encoding, cb) { | |||
| 84 | 88 | r.on('end', common.mustCall(function() { | |
| 85 | 89 | assert.throws(function() { | |
| 86 | 90 | r.unshift(Buffer.allocUnsafe(1)); | |
| 87 | - }, /^Error: stream\.unshift\(\) after end event$/); | ||
| 91 | + }, common.expectsError({ | ||
| 92 | + code: 'ERR_STREAM_UNSHIFT_AFTER_END_EVENT', | ||
| 93 | + type: Error, | ||
| 94 | + message: 'stream.unshift() after end event' | ||
| 95 | + })); | ||
| 88 | 96 | w.end(); | |
| 89 | 97 | })); | |
| 90 | 98 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments