Skip to content

Commit

Permalink
Merge pull request #191 from dpaloucva/MOBILE-1181
Browse files Browse the repository at this point in the history
MOBILE-1181 errors: Ignore cordova error that happens in iOS
  • Loading branch information
jleyva committed Aug 31, 2015
2 parents 9f51809 + 71c0909 commit c86f9ab
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions www/errorreport.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,31 @@ window.onerror = function(msg, url, lineNumber) {
}
}

// Use setTimeout to prevent the following error if the app crashes right at the start:
// "The connection to the server was unsuccessful. (file:///android_asset/www/index.html)"
setTimeout(function() {
if (typeof msg == "string") {
var sendError,
confirmmsg = 'Unexpected error, please accept to report the bug so we can work on fixing it ' +
'(Internet connection required).';
if (msg.indexOf('Can\'t find variable: cordova') == -1) {
// Use setTimeout to prevent the following error if the app crashes right at the start:
// "The connection to the server was unsuccessful. (file:///android_asset/www/index.html)"
setTimeout(function() {
if (typeof msg == "string") {
var sendError,
confirmmsg = 'Unexpected error, please accept to report the bug so we can work on fixing it ' +
'(Internet connection required).';

sendError = confirm(confirmmsg);
if (sendError) {
// Wait for device ready so we can retrieve device data. In most cases device will already be ready.
document.addEventListener('deviceready', reportError);
// Report error if device ready isn't fired after 5 seconds.
setTimeout(reportError, 5000);
sendError = confirm(confirmmsg);
if (sendError) {
// Wait for device ready so we can retrieve device data. In most cases device will already be ready.
document.addEventListener('deviceready', reportError);
// Report error if device ready isn't fired after 5 seconds.
setTimeout(reportError, 5000);
}
}
}

// This may help debugging if we use logging apps in iOs or Android.
if (typeof console != "undefined" && typeof console.log == "function") {
console.log(msg);
}
}, 100);
// This may help debugging if we use logging apps in iOs or Android.
if (typeof console != "undefined" && typeof console.log == "function") {
console.log(msg);
}
}, 100);
}

// Let default error handler run.
return false;
};

0 comments on commit c86f9ab

Please sign in to comment.