| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -157,7 +157,7 @@ Transform.prototype.push = function(chunk, encoding) { | |||
| 157 | 157 | // an error, then that'll put the hurt on the whole operation. If you | |
| 158 | 158 | // never call cb(), then you'll never get another chunk. | |
| 159 | 159 | Transform.prototype._transform = function(chunk, encoding, cb) { | |
| 160 | - throw new Error('_transform() is not implemented'); | ||
| 160 | + throw new errors.Error('ERR_METHOD_NOT_IMPLEMENTED', '_transform'); | ||
| 161 | 161 | }; | |
| 162 | 162 | ||
| 163 | 163 | Transform.prototype._write = function(chunk, encoding, cb) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,6 +33,7 @@ const internalUtil = require('internal/util'); | |||
| 33 | 33 | const Stream = require('stream'); | |
| 34 | 34 | const Buffer = require('buffer').Buffer; | |
| 35 | 35 | const destroyImpl = require('internal/streams/destroy'); | |
| 36 | + const errors = require('internal/errors'); | ||
| 36 | 37 | ||
| 37 | 38 | util.inherits(Writable, Stream); | |
| 38 | 39 | ||
@@ -319,7 +320,7 @@ Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { | |||
| 319 | 320 | if (typeof encoding === 'string') | |
| 320 | 321 | encoding = encoding.toLowerCase(); | |
| 321 | 322 | if (!Buffer.isEncoding(encoding)) | |
| 322 | - throw new TypeError('Unknown encoding: ' + encoding); | ||
| 323 | + throw new errors.TypeError('ERR_UNKNOWN_ENCODING', encoding); | ||
| 323 | 324 | this._writableState.defaultEncoding = encoding; | |
| 324 | 325 | return this; | |
| 325 | 326 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,10 +27,13 @@ const t2 = new Transform({}); | |||
| 27 | 27 | t.end(Buffer.from('blerg')); | |
| 28 | 28 | t.resume(); | |
| 29 | 29 | ||
| 30 | - assert.throws(() => { | ||
| 30 | + common.expectsError(() => { | ||
| 31 | 31 | t2.end(Buffer.from('blerg')); | |
| 32 | - }, /^Error: _transform\(\) is not implemented$/); | ||
| 33 | - | ||
| 32 | + }, { | ||
| 33 | + type: Error, | ||
| 34 | + code: 'ERR_METHOD_NOT_IMPLEMENTED', | ||
| 35 | + message: 'The _transform method is not implemented' | ||
| 36 | + }); | ||
| 34 | 37 | ||
| 35 | 38 | process.on('exit', () => { | |
| 36 | 39 | assert.strictEqual(t._transform, _transform); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,7 +20,7 @@ | |||
| 20 | 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. | |
| 21 | 21 | ||
| 22 | 22 | 'use strict'; | |
| 23 | - require('../common'); | ||
| 23 | + const common = require('../common'); | ||
| 24 | 24 | const assert = require('assert'); | |
| 25 | 25 | ||
| 26 | 26 | const stream = require('stream'); | |
@@ -55,13 +55,17 @@ MyWritable.prototype._write = function(chunk, encoding, callback) { | |||
| 55 | 55 | m.end(); | |
| 56 | 56 | }()); | |
| 57 | 57 | ||
| 58 | - assert.throws(function changeDefaultEncodingToInvalidValue() { | ||
| 58 | + common.expectsError(function changeDefaultEncodingToInvalidValue() { | ||
| 59 | 59 | const m = new MyWritable(function(isBuffer, type, enc) { | |
| 60 | 60 | }, { decodeStrings: false }); | |
| 61 | 61 | m.setDefaultEncoding({}); | |
| 62 | 62 | m.write('bar'); | |
| 63 | 63 | m.end(); | |
| 64 | - }, /^TypeError: Unknown encoding: \[object Object\]$/); | ||
| 64 | + }, { | ||
| 65 | + type: TypeError, | ||
| 66 | + code: 'ERR_UNKNOWN_ENCODING', | ||
| 67 | + message: 'Unknown encoding: [object Object]' | ||
| 68 | + }); | ||
| 65 | 69 | ||
| 66 | 70 | (function checkVairableCaseEncoding() { | |
| 67 | 71 | const m = new MyWritable(function(isBuffer, type, enc) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments