npm.io
0.3.3 • Published 7 years ago

@gourmet/promise-main

Licence
MIT
Version
0.3.3
Deps
0
Size
3 kB
Vulns
0
Weekly
0
Stars
45

@gourmet/promise-main

Handles the top main promise of a console app.

Why?

Because all errors should be propagated properly to the top main promise and there must be only one error handler in a console app.

Basic usage

const promiseMain = require("@gourmet/promise-main");

function main() {
  // ... main function of a console app that returns a promise ...
}

// Instead of this
/*
main().catch(err => {
  console.error(err);
  process.exit(1);
});
*/

// Do this
promiseMain(main());