UNPKG

@sentry/core

Version:
25 lines (22 loc) 936 B
import { GLOBAL_OBJ } from '../utils/worldwide.js'; import { addHandler, maybeInstrument, triggerHandlers } from './handlers.js'; let _oldOnUnhandledRejectionHandler = null; function addGlobalUnhandledRejectionInstrumentationHandler(handler) { const type = "unhandledrejection"; addHandler(type, handler); maybeInstrument(type, instrumentUnhandledRejection); } function instrumentUnhandledRejection() { _oldOnUnhandledRejectionHandler = GLOBAL_OBJ.onunhandledrejection; GLOBAL_OBJ.onunhandledrejection = function(e) { const handlerData = e; triggerHandlers("unhandledrejection", handlerData); if (_oldOnUnhandledRejectionHandler) { return _oldOnUnhandledRejectionHandler.apply(this, arguments); } return true; }; GLOBAL_OBJ.onunhandledrejection.__SENTRY_INSTRUMENTED__ = true; } export { addGlobalUnhandledRejectionInstrumentationHandler }; //# sourceMappingURL=globalUnhandledRejection.js.map