Use event handlers instead of listeners for error handing
Summary: ^ Adding listeners was correctly intercepting events but the event object often lacked the information necessary to correctly triage and fix an issue. I discovered that by subscribing to these events directly, the event object did have the required information. Changelog: Use global window event handlers instead of listeners Reviewed By: antonk52 Differential Revision: D39809292 fbshipit-source-id: 8a0fc7b7cd86ea16e40f2dc383bc30364f6fc16c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2bf5410316
commit
dfdeffbc09
@@ -9,11 +9,11 @@
|
||||
|
||||
export const startGlobalErrorHandling = () => {
|
||||
if (typeof window !== 'undefined') {
|
||||
window.addEventListener('error', (event) => {
|
||||
console.error('"error" event intercepted:', event.error);
|
||||
});
|
||||
window.addEventListener('unhandledrejection', (event) => {
|
||||
window.onerror = (event) => {
|
||||
console.error('"onerror" event intercepted:', event);
|
||||
};
|
||||
window.onunhandledrejection = (event) => {
|
||||
console.error('"unhandledrejection" event intercepted:', event.reason);
|
||||
});
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user