Redirect window.onerror to uncaughtException.
authorCheng Zhao <zcbenz@gmail.com>
Sun, 15 Dec 2013 08:32:41 +0000 (16:32 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Sun, 15 Dec 2013 08:32:41 +0000 (16:32 +0800)
renderer/lib/init.coffee

index 32d3d2ac61d5eb4cee699fc20a9ceb54df1a819b..f481146ace6255078792eddd9d1e9b65de7e477d 100644 (file)
@@ -37,3 +37,11 @@ if window.location.protocol is 'file:'
 else
   global.__filename = __filename
   global.__dirname = __dirname
+
+# Redirect window.onerror to uncaughtException.
+window.onerror = (error) ->
+  if global.process.listeners('uncaughtException').length > 0
+    global.process.emit 'uncaughtException', error
+    true
+  else
+    false