UI for Zipcoin Blue

index.js 682B

12345678910111213141516171819202122232425262728293031323334353637
  1. 'use strict';
  2. var util = require('util');
  3. var onExit = require('signal-exit');
  4. var currentlyUnhandled = require('currently-unhandled');
  5. var installed = false;
  6. module.exports = function (log) {
  7. if (installed) {
  8. return;
  9. }
  10. installed = true;
  11. log = log || console.error;
  12. var listUnhandled = currentlyUnhandled();
  13. onExit(function () {
  14. var unhandledRejections = listUnhandled();
  15. if (unhandledRejections.length > 0) {
  16. unhandledRejections.forEach(function (x) {
  17. var err = x.reason;
  18. if (!(err instanceof Error)) {
  19. err = new Error('Promise rejected with value: ' + util.inspect(err));
  20. }
  21. log(err.stack);
  22. });
  23. process.exitCode = 1;
  24. }
  25. });
  26. };