I have a issue with throwing an error inside of a bluebird promise. Take the following code:
var Promise = require('bluebird');
var domain = require('domain');
var problem = function() {
return new Promise(function(resolve, reject){
reject(new Error('Oops!'));
});
};
domain.create()
.on('error', function(e){
console.log("Caught Error " + e.message)
process.exit(1);
})
.run(function() {
problem().done();
});
I would expect to see Caught Error Oops!
in the console. However it seems that the error is not caught inside of the domain and i'm seeing a fatal error and stack trace in the console.
Does anyone know why?