Skip to content

Instantly share code, notes, and snippets.

@joecliff
Last active August 29, 2015 14:00
Show Gist options
  • Save joecliff/11389049 to your computer and use it in GitHub Desktop.
Save joecliff/11389049 to your computer and use it in GitHub Desktop.
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