From da09a8dfcd53079153aa5bfaa5c8bfda953034d4 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 11 Jan 2012 18:45:22 -0500 Subject: [PATCH] Fix debug output of thrown errors At some point this switched to showing just the line on which the error occurred. --- chrome/content/zotero/xpcom/debug.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/debug.js b/chrome/content/zotero/xpcom/debug.js index b401d55986..d88d48e30e 100644 --- a/chrome/content/zotero/xpcom/debug.js +++ b/chrome/content/zotero/xpcom/debug.js @@ -46,7 +46,23 @@ Zotero.Debug = new function () { return; } - if (typeof message != 'string') { + // Properly display thrown Error objects + if (message && message.constructor) { + switch (message.constructor.name) { + case 'Error': + case 'EvalError': + case 'RangeError': + case 'ReferenceError': + case 'SyntaxError': + case 'TypeError': + case 'URIError': + message = "'message' => \"" + message.message + "\"\n" + + Zotero.Utilities.varDump(message) + "\n" + + message.stack; + break; + } + } + else if (typeof message != 'string') { message = Zotero.Utilities.varDump(message); }