improve error handling and logging
This commit is contained in:
parent
a3c41c785d
commit
aa2d324cab
1 changed files with 7 additions and 7 deletions
14
dist/static/assets/webcam.js
vendored
14
dist/static/assets/webcam.js
vendored
|
@ -425,8 +425,8 @@ window.onerror = function (msg, url, lineNumber, columnNo, error) {
|
||||||
// var fileInfo = getScriptOff(errorNum);
|
// var fileInfo = getScriptOff(errorNum);
|
||||||
// data = msg + ' (' + fileInfo[1] + ': line ' + fileInfo[0] + ')';
|
// data = msg + ' (' + fileInfo[1] + ': line ' + fileInfo[0] + ')';
|
||||||
// } else {
|
// } else {
|
||||||
var fileInfo = getScriptOff(lineNumber);
|
// var fileInfo = getScriptOff(lineNumber);
|
||||||
data = msg + ' (' + fileInfo[1] + ': line ' + fileInfo[0] + ')';
|
data = msg + ' (' + error.fileName + ': line ' + error.lineNumber + ')';
|
||||||
// }
|
// }
|
||||||
window.parent.postMessage([{
|
window.parent.postMessage([{
|
||||||
log: [{
|
log: [{
|
||||||
|
@ -434,23 +434,23 @@ window.onerror = function (msg, url, lineNumber, columnNo, error) {
|
||||||
data: [data],
|
data: [data],
|
||||||
id: Date.now().toString()
|
id: Date.now().toString()
|
||||||
}],
|
}],
|
||||||
source: fileInfo[1]
|
source: error.fileName
|
||||||
}], '*');
|
}], '*');
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
// catch rejected promises
|
// catch rejected promises
|
||||||
window.onunhandledrejection = function (event) {
|
window.onunhandledrejection = function (event) {
|
||||||
if (event.reason && event.reason.message && event.reason.stack){
|
if (event.reason && event.reason.message && event.reason.stack){
|
||||||
var errorNum = event.reason.stack.split('about:srcdoc:')[1].split(':')[0];
|
// var errorNum = event.reason.stack.split('about:srcdoc:')[1].split(':')[0];
|
||||||
var fileInfo = getScriptOff(errorNum);
|
// var fileInfo = getScriptOff(errorNum);
|
||||||
var data = event.reason.message + ' (' + fileInfo[1] + ': line ' + fileInfo[0] + ')';
|
var data = event.reason.message + ' (' + event.reason.stack + ': line ' + event.reason.stack.split("\n")[0] + ')';
|
||||||
window.parent.postMessage([{
|
window.parent.postMessage([{
|
||||||
log: [{
|
log: [{
|
||||||
method: 'error',
|
method: 'error',
|
||||||
data: [data],
|
data: [data],
|
||||||
id: Date.now().toString()
|
id: Date.now().toString()
|
||||||
}],
|
}],
|
||||||
source: fileInfo[1]
|
source: event.reason.stack.split("\n")[0]
|
||||||
}], '*');
|
}], '*');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue