File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,22 @@ export const hijackConsoleErrorsScript = (offs) => {
38
38
}], '*');
39
39
return false;
40
40
};
41
+ // catch rejected promises
42
+ window.onunhandledrejection = function (event) {
43
+ if (event.reason && event.reason.message && event.reason.stack){
44
+ var errorNum = event.reason.stack.split('about:srcdoc:')[1].split(':')[0];
45
+ var fileInfo = getScriptOff(errorNum);
46
+ var data = event.reason.message + ' (' + fileInfo[1] + ': line ' + fileInfo[0] + ')';
47
+ window.parent.postMessage([{
48
+ log: [{
49
+ method: 'error',
50
+ data: [data],
51
+ id: Date.now().toString()
52
+ }],
53
+ source: fileInfo[1]
54
+ }], '*');
55
+ }
56
+ };
41
57
` ;
42
58
return s ;
43
59
} ;
@@ -46,7 +62,7 @@ export const startTag = '@fs-';
46
62
47
63
export const getAllScriptOffsets = ( htmlFile ) => {
48
64
const offs = [ ] ;
49
- const hijackConsoleErrorsScriptLength = 36 ;
65
+ const hijackConsoleErrorsScriptLength = 52 ;
50
66
const embeddedJSStart = 'script crossorigin=""' ;
51
67
let foundJSScript = true ;
52
68
let foundEmbeddedJS = true ;
You can’t perform that action at this time.
0 commit comments