From: JP Richardson Date: Fri, 10 Jul 2015 19:38:03 +0000 (-0500) Subject: emit error object on process.on('uncaughtException') in renderer X-Git-Tag: v0.30.0~23^2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=d6ae874038400a0c9367f8a6c14d62e5a951c907;p=electron.git emit error object on process.on('uncaughtException') in renderer Chromium added the actual `error` object to the 5th parameter in `window.onerror`. This should be emitted as opposed to the `errorMsg` string. Worse yet, since `errorMsg` wasn't an instance of `Error`, any code that assumes this in any `process.on('uncaughtException')` handler would fail. Also, correctly emitting the error provides the stack trace. This is now an HTML5 standard. Sources: - https://html.spec.whatwg.org/multipage/webappapis.html#errorevent - https://mikewest.org/2013/08/debugging-runtime-errors-with-window-onerror - https://code.google.com/p/chromium/issues/detail?id=147127 --- diff --git a/atom/renderer/lib/init.coffee b/atom/renderer/lib/init.coffee index 47071562..19689155 100644 --- a/atom/renderer/lib/init.coffee +++ b/atom/renderer/lib/init.coffee @@ -77,7 +77,7 @@ if nodeIntegration in ['true', 'all', 'except-iframe', 'manual-enable-iframe'] global.__dirname = __dirname # Redirect window.onerror to uncaughtException. - window.onerror = (error) -> + window.onerror = (message, filename, lineno, colno, error) -> if global.process.listeners('uncaughtException').length > 0 global.process.emit 'uncaughtException', error true