Created
February 10, 2017 01:13
-
-
Save don/596289071a45b4d19a4362cd04be48ad to your computer and use it in GitHub Desktop.
Global error handler for debugging with PhoneGap Developer App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror | |
window.onerror = function (msg, url, lineNo, columnNo, error) { | |
var string = msg.toLowerCase(); | |
var substring = "script error"; | |
if (string.indexOf(substring) > -1){ | |
alert('Script Error: See Browser Console for Detail'); | |
} else { | |
var message = [ | |
'Message: ' + msg, | |
'URL: ' + url, | |
'Line: ' + lineNo, | |
'Column: ' + columnNo, | |
'Error object: ' + JSON.stringify(error) | |
].join('\n'); | |
console.log(message); | |
alert(message); | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment