Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

assert: manutally create stack trace message #5123

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ assert.AssertionError = function AssertionError(options) {
this.operator = options.operator;
var stackStartFunction = options.stackStartFunction || fail;

if (Error.captureStackTrace) {
Error.captureStackTrace(this, stackStartFunction);
}
Error.captureStackTrace(this, stackStartFunction);
this.stack = this.stack.substr(this.name.length);
this.stack = this.toString() + this.stack;
};

// assert.AssertionError instanceof Error
Expand Down
2 changes: 1 addition & 1 deletion test/message/error_exit.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Exiting with code=1
assert.js:*
throw new assert.AssertionError({
^
AssertionError
AssertionError: 1 == 2
at Object.<anonymous> (*test*message*error_exit.js:*:*)
at Module._compile (module.js:*:*)
at Object.Module._extensions..js (module.js:*:*)
Expand Down