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

This commit is contained in:
Jaya Allamsetty 2020-10-26 23:57:23 -04:00 committed by Jaya Allamsetty
parent d2046c2c8f
commit 30fc04ba61
1 changed files with 12 additions and 4 deletions

View File

@ -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);