diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-01-25 04:39:02 +0800 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2018-01-29 13:41:40 +0800 |
commit | 3ec79216f9d2300faac2a4fe07e0ca92afd9dcb9 (patch) | |
tree | 94cf51144c4ea0d0797be409e3a059707479fcd3 /test | |
parent | 368517c0dc2576e1f8f315e53d0cfebb22acf9e2 (diff) | |
download | android-node-v8-3ec79216f9d2300faac2a4fe07e0ca92afd9dcb9.tar.gz android-node-v8-3ec79216f9d2300faac2a4fe07e0ca92afd9dcb9.tar.bz2 android-node-v8-3ec79216f9d2300faac2a4fe07e0ca92afd9dcb9.zip |
errors: improve the description of ERR_INVALID_ARG_VALUE
- Allow user to customize why the argument is invalid
- Display the argument with util.inspect so null bytes can be
displayed properly.
PR-URL: https://github.com/nodejs/node/pull/18358
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-internal-errors.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/test/parallel/test-internal-errors.js b/test/parallel/test-internal-errors.js index e8904bba0e..67c1cd1d2f 100644 --- a/test/parallel/test-internal-errors.js +++ b/test/parallel/test-internal-errors.js @@ -351,10 +351,20 @@ assert.strictEqual( } { - const error = new errors.Error('ERR_INVALID_ARG_VALUE', 'foo', 'bar'); + const error = new errors.Error('ERR_INVALID_ARG_VALUE', 'foo', '\u0000bar'); assert.strictEqual( error.message, - 'The value "bar" is invalid for argument "foo"' + 'The argument \'foo\' is invalid. Received \'\\u0000bar\'' + ); +} + +{ + const error = new errors.Error( + 'ERR_INVALID_ARG_VALUE', + 'foo', { a: 1 }, 'must have property \'b\''); + assert.strictEqual( + error.message, + 'The argument \'foo\' must have property \'b\'. Received { a: 1 }' ); } |