diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2018-03-19 15:33:46 +0300 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2018-03-25 03:45:37 +0300 |
commit | c6b6c92185316e13738e6fa931fdd5303e381e46 (patch) | |
tree | c38af9cd1a0a8cd6eeb459af3adee4dfd390fdc6 /lib/internal/encoding.js | |
parent | eeb57022e6bada13955a19b15232a9ee4fe9b465 (diff) |
lib: always show ERR_INVALID_ARG_TYPE received part
This makes a effort to make sure all of these errors will actually
also show the received input.
On top of that it refactors a few tests for better maintainability.
It will also change the returned type to always be a simple typeof
instead of special handling null.
PR-URL: https://github.com/nodejs/node/pull/19445
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'lib/internal/encoding.js')
-rw-r--r-- | lib/internal/encoding.js | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/internal/encoding.js b/lib/internal/encoding.js index 9cd47f861f9..ae874c530cc 100644 --- a/lib/internal/encoding.js +++ b/lib/internal/encoding.js @@ -51,7 +51,7 @@ function validateDecoder(obj) { function validateArgument(prop, expected, propName, expectedName) { if (typeof prop !== expected) - throw new ERR_INVALID_ARG_TYPE(propName, expectedName); + throw new ERR_INVALID_ARG_TYPE(propName, expectedName, prop); } const CONVERTER_FLAGS_FLUSH = 0x1; @@ -391,7 +391,8 @@ function makeTextDecoderICU() { input = lazyBuffer().from(input); } else if (!isArrayBufferView(input)) { throw new ERR_INVALID_ARG_TYPE('input', - ['ArrayBuffer', 'ArrayBufferView']); + ['ArrayBuffer', 'ArrayBufferView'], + input); } validateArgument(options, 'object', 'options', 'Object'); @@ -460,7 +461,8 @@ function makeTextDecoderJS() { input.byteLength); } else { throw new ERR_INVALID_ARG_TYPE('input', - ['ArrayBuffer', 'ArrayBufferView']); + ['ArrayBuffer', 'ArrayBufferView'], + input); } validateArgument(options, 'object', 'options', 'Object'); |