Consider this block of code:
getUser(userId)
.catch(function(error){
crashreporter.reportError(\'User DB failed\', error);
// show us
You should just have one catch
for your chain, but you can add more context to the errors that are thrown in each function. For example, when an error condition occurs in chargeCreditCard
you could tack onto the error a message
property corresponding to what you want to report. Then in your catch
error handler you can pass that message
property into the reporter:
getUser(userId)
.then(chargeCreditCard)
.catch(reportError);
function reportError(error) {
crashreporter.reportError(error.message, error);
}