瀏覽代碼

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

j8
Jaya Allamsetty 4 年之前
父節點
當前提交
30fc04ba61
共有 1 個檔案被更改,包括 12 行新增4 行删除
  1. 12
    4
      react/features/base/lib-jitsi-meet/middleware.js

+ 12
- 4
react/features/base/lib-jitsi-meet/middleware.js 查看文件

@@ -104,8 +104,10 @@ function _setErrorHandlers() {
104 104
 
105 105
         // eslint-disable-next-line max-params
106 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 112
             if (oldOnErrorHandler) {
111 113
                 oldOnErrorHandler(message, source, lineno, colno, error);
@@ -115,8 +117,14 @@ function _setErrorHandlers() {
115 117
         const oldOnUnhandledRejection = window.onunhandledrejection;
116 118
 
117 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 129
             if (oldOnUnhandledRejection) {
122 130
                 oldOnUnhandledRejection(event);

Loading…
取消
儲存