Deep within my promise stack, I make this call:
function isNameAvailable(name) {
return registry.getName(name)
.then(function(result) {
return result ? false : true;
});
}
Unfortunately, and this is a programming error, registry was undefined. My node.js application did not print any error message. Any ideas why? I am using the bluebird promise library.
Edit
Here's the calling code. I just added the catch, but it's not catching anything.
function _checkAvailability(name) {
return isNameAvailable(name)
.then(function(isAvailabile) {
if (isAvailabile) {
return true;
}
else {
throw new NameNotAvailable('Name "' + name + '" is not available');
}
})
.catch(function(error) {
console.log('isNameAvailable threw', error);
throw error;
})
}
The stack should eventually roll back to the function that was called by express.js as a result of an HTTP request. That's one place where I am catching all errors and printing a stack trace (but obviously it is not printing anything):
function createUser(req, res) {
userService.createUser(req.body)
.then(function(user) {
res.status(201).send(user);
})
.catch(function(error) {
log.trace(error);
res.status(500).send({'message': error.toString()});
});
}