Created
April 3, 2020 02:00
-
-
Save cvan/18e067c813117a122121d449dfdfbfa6 to your computer and use it in GitHub Desktop.
capture JavaScript errors (useful for debugging Safari webviews - e.g., Chrome for iOS)
This file contains hidden or 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
/** | |
* Hijacks `window.onerror` for debugging Chrome for iOS (WebView) via `chrome://inspect`. | |
* | |
* @returns {string|undefined} | |
*/ | |
window.onerror = function(message, url, lineNumber, columnNumber, error) { | |
console.error( | |
[ | |
['Error message:', message].join(' '), | |
['URL:', url].join(' '), | |
['Line:', lineNumber].join(' '), | |
['Column:', columnNumber].join(' '), | |
['Full error:', error].join(' ') | |
].join('\n') | |
); | |
return false; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment