diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2018-01-23 14:07:18 +0100 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2018-01-24 13:16:09 +0100 |
commit | e65a6e81ef5e8c0afae4ffec852b662732114adb (patch) | |
tree | f07404a4983170a8cce56a481300a96ac3536d59 /doc | |
parent | 8e6e1c9dcc83843aa17225b14ef91b92f337aebb (diff) | |
download | android-node-v8-e65a6e81ef5e8c0afae4ffec852b662732114adb.tar.gz android-node-v8-e65a6e81ef5e8c0afae4ffec852b662732114adb.tar.bz2 android-node-v8-e65a6e81ef5e8c0afae4ffec852b662732114adb.zip |
assert: stricter ifError
This makes `assert.ifError` stricter by only accepting `null` and
`undefined` from now on. Before any truthy value was accepted.
PR-URL: https://github.com/nodejs/node/pull/18247
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/assert.md | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/doc/api/assert.md b/doc/api/assert.md index 80b3019ad8..04f312aa66 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -474,11 +474,15 @@ changes: pr-url: https://github.com/nodejs/node/pull/18247 description: Instead of throwing the original error it is now wrapped into a AssertionError that contains the full stack trace. + - version: REPLACEME + pr-url: https://github.com/nodejs/node/pull/18247 + description: Value may now only be `undefined` or `null`. Before any truthy + input was accepted. --> * `value` {any} -Throws `value` if `value` is truthy. This is useful when testing the `error` -argument in callbacks. +Throws `value` if `value` is not `undefined` or `null`. This is useful when +testing the `error` argument in callbacks. ```js const assert = require('assert').strict; @@ -486,9 +490,7 @@ const assert = require('assert').strict; assert.ifError(null); // OK assert.ifError(0); -// OK -assert.ifError(1); -// AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 1 +// AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 0 assert.ifError('error'); // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 'error' assert.ifError(new Error()); |