>To correct this a little, the proper way to catch with promises is .catch, not with a try-catch inside a .then - that is an antipattern.
Depends whether you can survive and continue from an exception inside the .then to the next step or not.
Depends whether you can survive and continue from an exception inside the .then to the next step or not.
e.g, naive example:
.then(() => {
var foo;
try {
foo = getFoo();
} catch (err) {
foo = 10; //some default value
}
return foo;
}).then( (foo) =>
etc.So you might not want to reject automatically inside then if getFoo raises, but recover and return a default value.
.then(getFoo)
.catch(err => 10) //some default value
.then( (foo) =>