From d7b68c66af4e62b572619bd924a84323023ba56e Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Thu, 10 Mar 2011 09:53:57 -0500 Subject: [PATCH] Fix error dispatching fullscreen autocmd again. --- common/content/autocommands.js | 2 +- common/modules/util.jsm | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/common/content/autocommands.js b/common/content/autocommands.js index 2d960c83..869c0cf8 100644 --- a/common/content/autocommands.js +++ b/common/content/autocommands.js @@ -143,7 +143,7 @@ var AutoCommands = Module("autocommands", { let lastPattern = null; var { url, doc } = args; if (url) - uri = util.newURI(url); + uri = util.createURI(url); else var { uri, doc } = buffer; diff --git a/common/modules/util.jsm b/common/modules/util.jsm index 10743df4..311bac63 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -964,7 +964,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), * @returns {nsIURI} */ // FIXME: createURI needed too? - newURI: function (uri, charset, base) services.io.newURI(uri, charset, base), + newURI: function newURI(uri, charset, base) this.withProperErrors("newURI", services.io, uri, charset, base), /** * Removes leading garbage prepended to URIs by the subscript @@ -1765,6 +1765,23 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), return res.filter(function (h) !set.add(seen, h.spec)); }, + /** + * Wraps native exceptions thrown by the called function so that a + * proper stack trace may be retrieved from them. + * + * @param {function|string} meth The method to call. + * @param {object} self The 'this' object of the method. + * @param ... Arguments to pass to *meth*. + */ + withProperErrors: function withProperErrors(meth, self) { + try { + return (callable(meth) ? meth : self[meth]).apply(self, Array.slice(arguments, withProperErrors.length)); + } + catch (e) { + throw e.stack ? e : Error(e); + } + }, + /** * Converts an E4X XML literal to a DOM node. Any attribute named * highlight is present, it is transformed into dactyl:highlight,