UNPKG

@mantris/appify

Version:
34 lines (26 loc) 611 B
'use strict' const { TEST } = require('sugar-env') const Sentry = require('@sentry/node') /** * @param {String} environment * @param {Object<String, Function>} logger * @returns {void} */ module.exports = function onUnhandledRejectionTrap (environment, logger) { if (environment === TEST) { return } process.on('unhandledRejection', (err) => { logger.error(err) const client = Sentry .getCurrentHub() .getClient() if (!client) { process.exit(1) } Sentry.captureException(err) client .close(3000) .then(() => { process.exit(1) }) }) }