2013-06-25 07:12:42 +02:00
|
|
|
|
'use strict';
|
2013-05-05 23:24:33 +02:00
|
|
|
|
(function () {
|
2013-05-04 01:50:22 +02:00
|
|
|
|
|
2013-07-13 01:30:52 +02:00
|
|
|
|
window.console = window.console || {};
|
|
|
|
|
window.console.log = window.console.log || function(){};
|
|
|
|
|
window.console.group = window.console.group || function(){};
|
|
|
|
|
window.console.groupEnd = window.console.groupEnd || function(){};
|
|
|
|
|
window.console.debug = window.console.debug || function(){};
|
|
|
|
|
window.console.warn = window.console.warn || function(){};
|
|
|
|
|
window.console.assert = window.console.assert || function(){};
|
2013-05-21 02:34:02 +02:00
|
|
|
|
|
2013-05-04 01:50:22 +02:00
|
|
|
|
window.alert = function (message) {
|
|
|
|
|
window.Messenger().post(message);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
window.onerror = function (msg, url, line) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
var a = document.createElement('a');
|
|
|
|
|
a.href = url;
|
2013-07-01 20:25:37 +02:00
|
|
|
|
var filename = a.pathname.split('/').pop();
|
|
|
|
|
|
|
|
|
|
//Suppress Firefox debug errors when console window is closed
|
|
|
|
|
if (filename.toLowerCase() === 'markupview.jsm') {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var messageText = filename + ' : ' + line + '</br>' + msg;
|
2013-05-04 01:50:22 +02:00
|
|
|
|
|
|
|
|
|
var message = {
|
|
|
|
|
message : messageText,
|
|
|
|
|
type : 'error',
|
2013-05-04 04:15:46 +02:00
|
|
|
|
hideAfter : 1000,
|
2013-05-04 01:50:22 +02:00
|
|
|
|
showCloseButton: true
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
window.Messenger().post(message);
|
|
|
|
|
|
2013-06-25 07:12:42 +02:00
|
|
|
|
}
|
|
|
|
|
catch (error) {
|
2013-06-22 08:24:24 +02:00
|
|
|
|
console.log('An error occurred while reporting error. ' + error);
|
2013-05-04 01:50:22 +02:00
|
|
|
|
console.log(msg);
|
|
|
|
|
window.alert('Couldn\'t report JS error. ' + msg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false; //don't suppress default alerts and logs.
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$(document).ajaxError(function (event, xmlHttpRequest, ajaxOptions) {
|
|
|
|
|
|
|
|
|
|
//don't report 200 error codes
|
|
|
|
|
if (xmlHttpRequest.status >= 200 && xmlHttpRequest.status <= 300) {
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//don't report aborted requests
|
|
|
|
|
if (xmlHttpRequest.statusText === 'abort') {
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var message = {
|
|
|
|
|
type : 'error',
|
2013-05-04 04:15:46 +02:00
|
|
|
|
hideAfter : 1000,
|
2013-05-04 01:50:22 +02:00
|
|
|
|
showCloseButton: true
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (xmlHttpRequest.status === 0 && xmlHttpRequest.readyState === 0) {
|
2013-05-29 07:03:43 +02:00
|
|
|
|
return false;
|
|
|
|
|
//message.message = 'NzbDrone Server Not Reachable. make sure NzbDrone is running.';
|
2013-06-25 07:12:42 +02:00
|
|
|
|
}
|
2013-08-22 02:36:35 +02:00
|
|
|
|
else if (xmlHttpRequest.status === 400 && ajaxOptions.isValidatedCall) {
|
|
|
|
|
return false;
|
2013-05-04 01:50:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-08-22 02:36:35 +02:00
|
|
|
|
|
|
|
|
|
message.message = '[{0}] {1} : {2}'.format(ajaxOptions.type, xmlHttpRequest.statusText, ajaxOptions.url);
|
|
|
|
|
|
2013-05-04 01:50:22 +02:00
|
|
|
|
window.Messenger().post(message);
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
2013-05-05 23:24:33 +02:00
|
|
|
|
})();
|
2013-05-04 01:50:22 +02:00
|
|
|
|
|