Last active
August 29, 2015 14:00
-
-
Save joecliff/11389049 to your computer and use it in GitHub Desktop.
preferable error handler location for promise style codes in nodejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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