Skip to content

Commit 1f1fcf7

Browse files
author
James Halliday
committed
better error messages with stack traces
1 parent 37f79d2 commit 1f1fcf7

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

lib/render.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ function encodeResult (res, count) {
8181
output += inner + 'expected: ' + ex + '\n';
8282
output += inner + 'actual: ' + ac + '\n';
8383
}
84+
if (res.operator === 'error' && res.actual && res.actual.stack) {
85+
var lines = String(res.actual.stack).split('\n');
86+
output += inner + 'stack:\n';
87+
output += inner + ' ' + lines[0] + '\n';
88+
for (var i = 1; i < lines.length; i++) {
89+
output += inner + lines[i] + '\n';
90+
}
91+
}
8492

8593
output += outer + '...\n';
8694
}

lib/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ Test.prototype.error
184184
= Test.prototype.iferror
185185
= function (err, msg, extra) {
186186
this._assert(!err, {
187-
message : defined(msg, err.message),
187+
message : defined(msg, String(err)),
188188
operator : 'error',
189189
actual : err,
190190
extra : extra

test/throw.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ tap.test('throw test', function (tt) {
2121
'TAP version 13',
2222
'thrower',
2323
{ id: 1, ok: true, name: 'should be equal' },
24-
{ id: 2, ok: false, name: 'rawr' },
24+
{ id: 2, ok: false, name: 'Error: rawr' },
2525
'tests 2',
2626
'pass 1',
2727
'fail 1',

0 commit comments

Comments
 (0)