the .then(onSuccess, onError) anti-pattern
Before:
somePromise().then(
function onSuccess (res) {
// stuff happens, but oh no!
// an error is thrown in here!
},
function onError (err) {
// request-only error handler
}
);
After:
somePromise()
.then(function onSuccess (res) {
// stuff happens, but oh no!
// an error is thrown in here!
})
.catch(function onError (err) {
// yay! The error thrown in the function above
// can be handled here or rethrown to be handled elsewhere.
});
More details here.
Written on October 5, 2016 by jasonkurian