0

Why do I need both? What is the difference

Between

.then(doWork, errorHandler)

… and …

.then(doWork) .catch(errorHandler)

Is it a matter of convenience and both will catch errors? Do I need to use both or only one? On which use cases?

Jas
  • 14,493
  • 27
  • 97
  • 148
  • Another possible dupe: [Promise : then vs then + catch](http://stackoverflow.com/q/33278280/5743988) – 4castle Nov 03 '16 at 05:49

1 Answers1

1

In the first code snippet, if the success handler throws an exception or rejects a promise, execution will not go into the error handler since the promise was already resolved at this level.

With catch, you can always see an unhandled error from the previous success handler.

Abhyudit Jain
  • 3,640
  • 2
  • 24
  • 32