Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
preferable error handler location for promise style codes in nodejs
/**
* always put errorHandler in the last 'then' with a 'null' logic handler,
* so that all errors will be caught
*/
someModule.promiseFunc()
.then(function (data) {
//TODO other logic
})
.then(null, errorHandler);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment