Home

Awesome

uncaught Build Status npm version

uncaught is the module, which allows you to handle all uncaught errors and promise rejections through only one listener.

How it works

uncaught listens for global object errors and unhandled rejections events:

After one of these events fires, the module transfers error (and also event for browser mode) object(s) to all registered listeners functions.

Browser support

Global error

Global unhandled rejection

Node.js support

Install

$ npm install --save uncaught

Usage examples

Browser

<body>
    ...
    <script src="path_to_your_project_dir/node_modules/uncaught/lib/index.js"></script>
    <script>
        uncaught.start();
        uncaught.addListener(function (error) {
            console.log('Uncaught error or rejection: ', error.message);
        });
    </script>
    ...
</body>

Browser + webpack

var uncaught = require('uncaught');

uncaught.start();
uncaught.addListener(function (error) {
    console.log('Uncaught error or rejection: ', error.message);
});

Node.js

var uncaught = require('uncaught');

uncaught.start();
uncaught.addListener(function (error) {
    console.log('Uncaught error or rejection: ', error.message);
});

API

List of methods for module management:

License

MIT © https://github.com/aleksandr-oleynikov