If you are on the server side, you can use promise rejection traps. They will work with most server-side promise implementations (io.js, bluebird, when, etc.):
process.on("unhandledRejection", function(promise, reason){
If you are in a browser environment, everything becomes less standardized. However, when there are still similar hooks:
window.addEventListener('unhandledRejection', function(event) { event.preventDefault();
There are also local rollback hooks, they are good if you want to handle the deviations of one instance of the promise library - this is usually useful when creating the library yourself:
var Promise = require('when').Promise; Promise.onPotentiallyUnhandledRejection = function(rejection) {
source share