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) => {
3838 }], '*');
3939 return false;
4040 };
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+ };
4157 ` ;
4258 return s ;
4359} ;
@@ -46,7 +62,7 @@ export const startTag = '@fs-';
4662
4763export const getAllScriptOffsets = ( htmlFile ) => {
4864 const offs = [ ] ;
49- const hijackConsoleErrorsScriptLength = 36 ;
65+ const hijackConsoleErrorsScriptLength = 52 ;
5066 const embeddedJSStart = 'script crossorigin=""' ;
5167 let foundJSScript = true ;
5268 let foundEmbeddedJS = true ;
You can’t perform that action at this time.
0 commit comments