This is a more comprehensive version of #381 that I made last autumn as part of my investigations into a node 14 upgrade.
I did a few things…
Move AssertError to errors.js and make it a named export.
Set the name property to AssertError.
Refactor to make the message massaging a part of Hoek.assert() instead of the error itself. This means that a lib that imports to test for the AssertError type, won't also have to load the stringify.js module.
Allow creator to specify a custom constructor function to simplify the stack trace.
Fix error in assert() simplification of the stack trace (exports.assert was always undefined).
Additional testing.
I also took the liberty to add the throws condition clause to the assert() typings, which can help narrow type signatures.
Note that this is a breaking change due to the renaming, but also from the updated constructor signature.
This is a more comprehensive version of #381 that I made last autumn as part of my investigations into a node 14 upgrade.
I did a few things…
AssertError
toerrors.js
and make it a named export.name
property toAssertError
.message
massaging a part ofHoek.assert()
instead of the error itself. This means that a lib that imports to test for theAssertError
type, won't also have to load thestringify.js
module.assert()
simplification of the stack trace (exports.assert
was alwaysundefined
).I also took the liberty to add the
throws condition
clause to theassert()
typings, which can help narrow type signatures.Note that this is a breaking change due to the renaming, but also from the updated constructor signature.