This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/loud-rejection/index.js

37 lines
682 B
JavaScript
Raw Permalink Normal View History

2019-08-11 18:48:02 +00:00
'use strict';
var util = require('util');
var onExit = require('signal-exit');
var currentlyUnhandled = require('currently-unhandled');
var installed = false;
module.exports = function (log) {
if (installed) {
return;
}
installed = true;
log = log || console.error;
var listUnhandled = currentlyUnhandled();
onExit(function () {
var unhandledRejections = listUnhandled();
if (unhandledRejections.length > 0) {
unhandledRejections.forEach(function (x) {
var err = x.reason;
if (!(err instanceof Error)) {
err = new Error('Promise rejected with value: ' + util.inspect(err));
}
log(err.stack);
});
process.exitCode = 1;
}
});
};