From 424aacc4669697bd8032276cdac2339ccad1181b Mon Sep 17 00:00:00 2001 From: lukasz Date: Sat, 30 Dec 2017 21:59:27 +0100 Subject: [PATCH] fix(common): more detailed info about error --- common/stringify.js | 2 ++ test/client/stringify.spec.js | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/common/stringify.js b/common/stringify.js index 8b07abc08..6df1d3e97 100644 --- a/common/stringify.js +++ b/common/stringify.js @@ -54,6 +54,8 @@ var stringify = function stringify (obj, depth) { return obj.outerHTML } else if (isNode(obj)) { return serialize(obj) + } else if (instanceOf(obj, 'Error')) { + return obj.toString() + '\n' + obj.stack } else { var constructor = 'Object' if (obj.constructor && typeof obj.constructor === 'function') { diff --git a/test/client/stringify.spec.js b/test/client/stringify.spec.js index 241828295..603c2df03 100644 --- a/test/client/stringify.spec.js +++ b/test/client/stringify.spec.js @@ -86,6 +86,11 @@ describe('stringify', function () { assert.deepEqual(stringify(div).trim().toLowerCase(), '
some text
') }) + it('should serialize error', function () { + var error = new TypeError('Error description') + assert(stringify(error).indexOf('Error description') > -1) + }) + it('should serialize DOMParser objects', function () { if (typeof DOMParser !== 'undefined') { // Test only works in IE 9 and above