summaryrefslogtreecommitdiff
path: root/doc/api/assert.md
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2018-01-19 10:35:39 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2018-01-24 13:16:07 +0100
commit72bb4445c64af98f3e481c11320afbfb995f010c (patch)
tree282d7240fb99f92a2332a74b6044f04317b5b78a /doc/api/assert.md
parent7a23fc076045e767b922343c226d8492cc98cb93 (diff)
downloadandroid-node-v8-72bb4445c64af98f3e481c11320afbfb995f010c.tar.gz
android-node-v8-72bb4445c64af98f3e481c11320afbfb995f010c.tar.bz2
android-node-v8-72bb4445c64af98f3e481c11320afbfb995f010c.zip
assert: wrap original error in ifError
It is hard to know where ifError is actually triggered due to the original error being thrown. This changes it by wrapping the original error in a AssertionError. This has the positive effect of also making clear that it is indeed a assertion function that triggered that error. The original stack can still be accessed by checking the `actual` property. 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/api/assert.md')
-rw-r--r--doc/api/assert.md11
1 files changed, 8 insertions, 3 deletions
diff --git a/doc/api/assert.md b/doc/api/assert.md
index 339351db8b..80b3019ad8 100644
--- a/doc/api/assert.md
+++ b/doc/api/assert.md
@@ -469,6 +469,11 @@ suppressFrame();
## assert.ifError(value)
<!-- YAML
added: v0.1.97
+changes:
+ - version: REPLACEME
+ 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.
-->
* `value` {any}
@@ -483,11 +488,11 @@ assert.ifError(null);
assert.ifError(0);
// OK
assert.ifError(1);
-// Throws 1
+// AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 1
assert.ifError('error');
-// Throws 'error'
+// AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 'error'
assert.ifError(new Error());
-// Throws Error
+// AssertionError [ERR_ASSERTION]: ifError got unwanted exception: Error
```
## assert.notDeepEqual(actual, expected[, message])