I'm currently trying to debug a javascript error that occurs within a Cordova app's InAppBrowser (on Android). Unfortunately, although I can connect to the web-view on the phone using chrome's remote debugging/inspection tools, the console output is empty, despite the fact that it shouldn't be. (There's misc messages/warnings that should be showing up regardless of hitting the issue or not.)
At this point, I've hit a wall on trying to get the console/error messages. Nothing seems to work. Can anyone think of a way I could tell the webview/javascript to forward all error messages to a remote address? (Obviously, I'd never ship an app with this sort of configuration.)
If it's a JavaScript error, you might be able to catch it with window.onerror
. The idea is to catch the error then post it to a logging server.
window.onerror = function (msg, url, lineNo, columnNo, error) {
alert(msg)
// Log error to external server.
// axios.post(url, JSON.stringify({msg, url, lineNo, columnNo, error}))
}
const test = undefined
test.error
I do this in my production environments. This helps to catch errors and notify me of the issue faster.