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);
|
||||
// data = msg + ' (' + fileInfo[1] + ': line ' + fileInfo[0] + ')';
|
||||
// } else {
|
||||
var fileInfo = getScriptOff(lineNumber);
|
||||
data = msg + ' (' + fileInfo[1] + ': line ' + fileInfo[0] + ')';
|
||||
// var fileInfo = getScriptOff(lineNumber);
|
||||
data = msg + ' (' + error.fileName + ': line ' + error.lineNumber + ')';
|
||||
// }
|
||||
window.parent.postMessage([{
|
||||
log: [{
|
||||
|
@ -434,23 +434,23 @@ window.onerror = function (msg, url, lineNumber, columnNo, error) {
|
|||
data: [data],
|
||||
id: Date.now().toString()
|
||||
}],
|
||||
source: fileInfo[1]
|
||||
source: error.fileName
|
||||
}], '*');
|
||||
return false;
|
||||
};
|
||||
// catch rejected promises
|
||||
window.onunhandledrejection = function (event) {
|
||||
if (event.reason && event.reason.message && event.reason.stack){
|
||||
var errorNum = event.reason.stack.split('about:srcdoc:')[1].split(':')[0];
|
||||
var fileInfo = getScriptOff(errorNum);
|
||||
var data = event.reason.message + ' (' + fileInfo[1] + ': line ' + fileInfo[0] + ')';
|
||||
// var errorNum = event.reason.stack.split('about:srcdoc:')[1].split(':')[0];
|
||||
// var fileInfo = getScriptOff(errorNum);
|
||||
var data = event.reason.message + ' (' + event.reason.stack + ': line ' + event.reason.stack.split("\n")[0] + ')';
|
||||
window.parent.postMessage([{
|
||||
log: [{
|
||||
method: 'error',
|
||||
data: [data],
|
||||
id: Date.now().toString()
|
||||
}],
|
||||
source: fileInfo[1]
|
||||
source: event.reason.stack.split("\n")[0]
|
||||
}], '*');
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue