Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private _handleUnhandledRejections(): void {
if (this._options.onunhandledrejection) {
// tslint:disable-next-line: no-implicit-dependencies
const tracking = require("promise/setimmediate/rejection-tracking");
tracking.disable();
tracking.enable({
allRejections: true,
onHandled: () => {
// We do nothing
},
onUnhandled: (id: any, error: any) => {
getCurrentHub().captureException(error, {
data: { id },
originalException: error
});
}
});
}
}
}
// Make sure that if multiple fatals occur, we only persist the first one.
//
// The first error is probably the most important/interesting error, and we
// want to crash ASAP, rather than potentially queueing up multiple errors.
var handlingFatal = false;
var defaultHandler =
(ErrorUtils.getGlobalHandler && ErrorUtils.getGlobalHandler()) ||
ErrorUtils._globalHandler;
if (options.handlePromiseRejection) {
// Track unhandled promise rejections
var tracking = require('promise/setimmediate/rejection-tracking');
tracking.disable();
tracking.enable({
allRejections: true,
onUnhandled: function(id, error) {
var captureOptions = {
timestamp: new Date() / 1000,
type: 'Unhandled Promise Rejection'
};
Raven.captureException(error, captureOptions);
},
onHandled: function() {}
});
}
ErrorUtils.setGlobalHandler(function(error, isFatal) {
var captureOptions = {
timestamp: new Date() / 1000
private _handleUnhandledRejections(): void {
if (this._options.onunhandledrejection) {
const tracking = require("promise/setimmediate/rejection-tracking");
tracking.disable();
tracking.enable({
allRejections: true,
onUnhandled: (id: any, error: any) => {
console.log(id, error);
},
onHandled: function() {}
});
}
}