Sfoglia il codice sorgente

fix(logging): Add more details to onerror and onunhandledrejection errors.

j8
Jaya Allamsetty 4 anni fa
parent
commit
30fc04ba61
1 ha cambiato i file con 12 aggiunte e 4 eliminazioni
  1. 12
    4
      react/features/base/lib-jitsi-meet/middleware.js

+ 12
- 4
react/features/base/lib-jitsi-meet/middleware.js Vedi File

104
 
104
 
105
         // eslint-disable-next-line max-params
105
         // eslint-disable-next-line max-params
106
         window.onerror = (message, source, lineno, colno, error) => {
106
         window.onerror = (message, source, lineno, colno, error) => {
107
-            JitsiMeetJS.getGlobalOnErrorHandler(
108
-                message, source, lineno, colno, error);
107
+            const errMsg = message || (error && error.message);
108
+            const stack = error && error.stack;
109
+
110
+            JitsiMeetJS.getGlobalOnErrorHandler(errMsg, source, lineno, colno, stack);
109
 
111
 
110
             if (oldOnErrorHandler) {
112
             if (oldOnErrorHandler) {
111
                 oldOnErrorHandler(message, source, lineno, colno, error);
113
                 oldOnErrorHandler(message, source, lineno, colno, error);
115
         const oldOnUnhandledRejection = window.onunhandledrejection;
117
         const oldOnUnhandledRejection = window.onunhandledrejection;
116
 
118
 
117
         window.onunhandledrejection = function(event) {
119
         window.onunhandledrejection = function(event) {
118
-            JitsiMeetJS.getGlobalOnErrorHandler(
119
-                null, null, null, null, event.reason);
120
+            let message = event.reason;
121
+            let stack = 'n/a';
122
+
123
+            if (event.reason instanceof Error) {
124
+                ({ message, stack } = event.reason);
125
+            }
126
+
127
+            JitsiMeetJS.getGlobalOnErrorHandler(message, null, null, null, stack);
120
 
128
 
121
             if (oldOnUnhandledRejection) {
129
             if (oldOnUnhandledRejection) {
122
                 oldOnUnhandledRejection(event);
130
                 oldOnUnhandledRejection(event);

Loading…
Annulla
Salva