From f1357866039d2c712a056035002aa9dee5d7d2e8 Mon Sep 17 00:00:00 2001 From: geek Date: Sat, 9 Sep 2017 20:36:47 -0500 Subject: [PATCH] assert: support custom errors --- doc/api/assert.md | 59 +++++++++++++++++++++---------- lib/assert.js | 2 ++ test/parallel/test-assert-fail.js | 22 ++++++++++++ test/parallel/test-assert.js | 28 +++++++++++++++ 4 files changed, 93 insertions(+), 18 deletions(-) diff --git a/doc/api/assert.md b/doc/api/assert.md index 254d4faf98bfbf..50bc22e0b66714 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -101,7 +101,9 @@ assert.deepEqual(obj1, obj4); If the values are not equal, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` -parameter is undefined, a default error message is assigned. +parameter is undefined, a default error message is assigned. If the `message` +parameter is an instance of an `Error` then it will be thrown instead of the +`AssertionError`. ## assert.deepStrictEqual(actual, expected[, message])