Only use unhandledrejection fallback when needed
This commit is contained in:
parent
36653517a5
commit
999b5da753
|
@ -1172,6 +1172,7 @@ if (typeof document != 'undefined' && document.getElementsByTagName) {
|
||||||
function handleError(err) {
|
function handleError(err) {
|
||||||
// dispatch an error event so that we can display in errors in browsers
|
// dispatch an error event so that we can display in errors in browsers
|
||||||
// that don't yet support unhandledrejection
|
// that don't yet support unhandledrejection
|
||||||
|
if (window.onunhandledrejection === undefined) {
|
||||||
try {
|
try {
|
||||||
var evt = new Event('error');
|
var evt = new Event('error');
|
||||||
} catch (_eventError) {
|
} catch (_eventError) {
|
||||||
|
@ -1181,6 +1182,7 @@ if (typeof document != 'undefined' && document.getElementsByTagName) {
|
||||||
evt.message = err.message;
|
evt.message = err.message;
|
||||||
evt.error = err;
|
evt.error = err;
|
||||||
window.dispatchEvent(evt);
|
window.dispatchEvent(evt);
|
||||||
|
}
|
||||||
|
|
||||||
// throw so it still shows up in the console
|
// throw so it still shows up in the console
|
||||||
throw err;
|
throw err;
|
||||||
|
|
|
@ -12,6 +12,7 @@ if (typeof document != 'undefined' && document.getElementsByTagName) {
|
||||||
function handleError(err) {
|
function handleError(err) {
|
||||||
// dispatch an error event so that we can display in errors in browsers
|
// dispatch an error event so that we can display in errors in browsers
|
||||||
// that don't yet support unhandledrejection
|
// that don't yet support unhandledrejection
|
||||||
|
if (window.onunhandledrejection === undefined) {
|
||||||
try {
|
try {
|
||||||
var evt = new Event('error');
|
var evt = new Event('error');
|
||||||
} catch (_eventError) {
|
} catch (_eventError) {
|
||||||
|
@ -21,6 +22,7 @@ if (typeof document != 'undefined' && document.getElementsByTagName) {
|
||||||
evt.message = err.message;
|
evt.message = err.message;
|
||||||
evt.error = err;
|
evt.error = err;
|
||||||
window.dispatchEvent(evt);
|
window.dispatchEvent(evt);
|
||||||
|
}
|
||||||
|
|
||||||
// throw so it still shows up in the console
|
// throw so it still shows up in the console
|
||||||
throw err;
|
throw err;
|
||||||
|
|
Loading…
Reference in New Issue