Skip to content

Instantly share code, notes, and snippets.

@kaizimmer
Created December 21, 2011 19:15
Show Gist options
  • Save kaizimmer/1507272 to your computer and use it in GitHub Desktop.
Save kaizimmer/1507272 to your computer and use it in GitHub Desktop.
Logs all errors passed to window.onerror handler
window.onerror = function ( descr, script, loc )
{
console.log("!!!!!!!!!!!");
console.log("!!! ERROR: " + JSON.stringify( { description: descr, script: script, line: loc } ));
console.log("!!!!!!!!!!!");
/*/
return true; //stops error propagation
//*/
};
@kaizimmer
Copy link
Author

Note:
Chrome: no custom errors supported (thrown by yourself) / line and file arguments not provided
Internet Explorer: Error objects other than "Error" (e.g. "TypeError") not supported
Opera: no support at all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment