From 72bb4445c64af98f3e481c11320afbfb995f010c Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Fri, 19 Jan 2018 10:35:39 +0100 Subject: 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 Reviewed-By: James M Snell --- doc/api/assert.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'doc/api/assert.md') 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) * `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]) -- cgit v1.2.3