Skip to content

Latest commit

 

History

History
17 lines (13 loc) · 569 Bytes

promiseRejectionAutoHandle.md

File metadata and controls

17 lines (13 loc) · 569 Bytes

jinang/promiseRejectionAutoHandle

By default, an instance of Promise without .catch(onReject) will throw an exception while it is rejected. promiseRejectionAutoHandle will catch the exception automatically in such situations.

const handler = (err) => console.log(err);
require('jinang/promiseRejectionAutoHandle')(handler);
// The *handler* is not required

new Promise((resolve, reject) => { /* ... */ })
    .then(data => {
        /* ... */
    })
    ;

Read unit test code for more examples.