Closed cowwoc closed 11 years ago
promise.catch(function (error) {
setTimeout(function () { throw error; }, 0);
});
@domenic
Thank you. Is it possible to add this to the documentation or add throwUncaughtError()
to the API?
A more generic solution might be to add a reportUnhandledError() function somewhere globally.
+1 to @sicking. Related: http://lists.w3.org/Archives/Public/www-dom/2013AprJun/0188.html
@cowwoc I'll leave any documentation changes to @slightlyoff. I'm not sure he intended this polyfill to be actually used in production, more than as a proof of concept. If it's the former, there's surely a lot of work to do.
@domenic "high-fidelity polyfill" tends to give the impression that this might be intended as code that could be used in production. if that's not the case then that wording should probably be toned down a little.
The latest version of Promise places the done() method with catch(). The problem is that under Google Chrome you cannot do the following:
because
window.onerror
is undefined, and you cannotthrow error;
because the Promise will catch the error and translate it into aPromise.reject()
which is never handled.In short, there is no practical way to cause errors to bubble up to the browser's default exception handler. Yes, I can log the error myself but I should be able to push exceptions to the default handler.