1 # loud-rejection [![Build Status](https://travis-ci.org/sindresorhus/loud-rejection.svg?branch=master)](https://travis-ci.org/sindresorhus/loud-rejection) [![Coverage Status](https://coveralls.io/repos/github/sindresorhus/loud-rejection/badge.svg?branch=master)](https://coveralls.io/github/sindresorhus/loud-rejection?branch=master)
3 > Make unhandled promise rejections fail loudly instead of the default [silent fail](https://gist.github.com/benjamingr/0237932cee84712951a2)
5 By default, promises fail silently if you don't attach a `.catch()` handler to them.
7 Use this in top-level things like tests, CLI tools, apps, etc, **but not in reusable modules.**<br>
8 Not needed in the browser as unhandled promises are shown in the console.
14 $ npm install --save loud-rejection
21 const loudRejection = require('loud-rejection');
22 const promiseFn = require('promise-fn');
24 // Install the unhandledRejection listeners
30 Without this module it's more verbose and you might even miss some that will fail silently:
33 const promiseFn = require('promise-fn');
36 console.error(err.stack);
40 promiseFn().catch(error);
45 Alternatively to the above, you may simply require `loud-rejection/register` and the unhandledRejection listener will be automagically installed for you.
47 This is handy for ES2015 imports:
50 import 'loud-rejection/register';
56 ### loudRejection([log])
61 Default: `console.error`
63 Custom logging function to print the rejected promise. Receives the error stack.
68 MIT © [Sindre Sorhus](https://sindresorhus.com)