assert: put info in err.message, not err.name
authorRyan Doenges <rhdoenges@gmail.com>
Sun, 14 Apr 2013 01:48:00 +0000 (18:48 -0700)
committerisaacs <i@izs.me>
Thu, 18 Apr 2013 22:08:35 +0000 (15:08 -0700)
commit6101eb184db77d0b11eb96e48744e57ecce4b73d
treefed10b1c4cbe55267169e99b7c458aa267cbbc5e
parenta835a2fc47d55c95c03780a78af09f971637a351
assert: put info in err.message, not err.name

4716dc6 made assert.equal() and related functions work better by
generating a better toString() from the expected, actual, and operator
values passed to fail(). Unfortunately, this was accomplished by putting
the generated message into the error's `name` property. When you passed
in a custom error message, the error would put the custom error into
`name` *and* `message`, resulting in helpful string representations like
"AssertionError: Oh no: Oh no".

This commit resolves that issue by storing the generated message in the
`message` property while leaving the error's name alone and adding
a regression test so that this doesn't pop back up later.

Closes #5292.
lib/assert.js
test/simple/test-assert.js