@airbrake/browser
Version:
Official Airbrake notifier for browsers
40 lines • 1.5 kB
JavaScript
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
export function instrumentUnhandledrejection(notifier) {
var handler = onUnhandledrejection.bind(notifier);
window.addEventListener('unhandledrejection', handler);
notifier._onClose.push(function () {
window.removeEventListener('unhandledrejection', handler);
});
}
function onUnhandledrejection(e) {
// Handle native or bluebird Promise rejections
// https://developer.mozilla.org/en-US/docs/Web/Events/unhandledrejection
// http://bluebirdjs.com/docs/api/error-management-configuration.html
var reason = e.reason || (e.detail && e.detail.reason);
if (!reason)
return;
var msg = reason.message || String(reason);
if (msg.indexOf && msg.indexOf('airbrake: ') === 0)
return;
if (typeof reason !== 'object' || reason.error === undefined) {
this.notify({
error: reason,
context: {
unhandledRejection: true,
},
});
return;
}
this.notify(__assign(__assign({}, reason), { context: { unhandledRejection: true } }));
}
//# sourceMappingURL=unhandledrejection.js.map