jskatas.org Continuously Learn JavaScript. Your Way.

Promise: promise.catch()

Returns a Promise and deals with rejected cases only.

Donate to NGO Julenka. Support Ukranians in need. Julenka is an NGO which my brother founded in 2011 to support Ukranian families and kids in need.

catch() returns a Promise and deals with rejected cases only

prerequisites for understanding

  • return a fulfilled promise, to pass a test
  • reminder: the test passes when a fulfilled promise is returned

catch method basics

  • is an instance method
  • catches only promise rejections
  • returns a new promise
  • converts it`s return value into a promise
  • the first parameter is the rejection reason

multiple catches

  • only the first catch is called
  • if a catch throws, the next catch catches it

Links

A short description of how `catch` works.
The actual chapter about `catch`, you need to dive in from here.
The description of the actual flow of `catch`.