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 // eslint-disable-next-line max-params
window.onerror = (message, source, lineno, colno, error) => { window.onerror = (message, source, lineno, colno, error) => {
JitsiMeetJS.getGlobalOnErrorHandler( const errMsg = message || (error && error.message);
message, source, lineno, colno, error); const stack = error && error.stack;
JitsiMeetJS.getGlobalOnErrorHandler(errMsg, source, lineno, colno, stack);
if (oldOnErrorHandler) { if (oldOnErrorHandler) {
oldOnErrorHandler(message, source, lineno, colno, error); oldOnErrorHandler(message, source, lineno, colno, error);
@ -115,8 +117,14 @@ function _setErrorHandlers() {
const oldOnUnhandledRejection = window.onunhandledrejection; const oldOnUnhandledRejection = window.onunhandledrejection;
window.onunhandledrejection = function(event) { window.onunhandledrejection = function(event) {
JitsiMeetJS.getGlobalOnErrorHandler( let message = event.reason;
null, null, null, null, event.reason); let stack = 'n/a';
if (event.reason instanceof Error) {
({ message, stack } = event.reason);
}
JitsiMeetJS.getGlobalOnErrorHandler(message, null, null, null, stack);
if (oldOnUnhandledRejection) { if (oldOnUnhandledRejection) {
oldOnUnhandledRejection(event); oldOnUnhandledRejection(event);