Skip to content

Commit 424aacc

Browse files
committed
fix(common): more detailed info about error
1 parent fca048b commit 424aacc

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

common/stringify.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ var stringify = function stringify (obj, depth) {
5454
return obj.outerHTML
5555
} else if (isNode(obj)) {
5656
return serialize(obj)
57+
} else if (instanceOf(obj, 'Error')) {
58+
return obj.toString() + '\n' + obj.stack
5759
} else {
5860
var constructor = 'Object'
5961
if (obj.constructor && typeof obj.constructor === 'function') {

test/client/stringify.spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ describe('stringify', function () {
8686
assert.deepEqual(stringify(div).trim().toLowerCase(), '<div>some <span>text</span></div>')
8787
})
8888

89+
it('should serialize error', function () {
90+
var error = new TypeError('Error description')
91+
assert(stringify(error).indexOf('Error description') > -1)
92+
})
93+
8994
it('should serialize DOMParser objects', function () {
9095
if (typeof DOMParser !== 'undefined') {
9196
// Test only works in IE 9 and above

0 commit comments

Comments
 (0)