diff --git a/react/features/base/lib-jitsi-meet/middleware.js b/react/features/base/lib-jitsi-meet/middleware.js index 5068d0b1e..5adf8d498 100644 --- a/react/features/base/lib-jitsi-meet/middleware.js +++ b/react/features/base/lib-jitsi-meet/middleware.js @@ -104,8 +104,10 @@ function _setErrorHandlers() { // eslint-disable-next-line max-params window.onerror = (message, source, lineno, colno, error) => { - JitsiMeetJS.getGlobalOnErrorHandler( - message, source, lineno, colno, error); + const errMsg = message || (error && error.message); + const stack = error && error.stack; + + JitsiMeetJS.getGlobalOnErrorHandler(errMsg, source, lineno, colno, stack); if (oldOnErrorHandler) { oldOnErrorHandler(message, source, lineno, colno, error); @@ -115,8 +117,14 @@ function _setErrorHandlers() { const oldOnUnhandledRejection = window.onunhandledrejection; window.onunhandledrejection = function(event) { - JitsiMeetJS.getGlobalOnErrorHandler( - null, null, null, null, event.reason); + let message = event.reason; + let stack = 'n/a'; + + if (event.reason instanceof Error) { + ({ message, stack } = event.reason); + } + + JitsiMeetJS.getGlobalOnErrorHandler(message, null, null, null, stack); if (oldOnUnhandledRejection) { oldOnUnhandledRejection(event);