Promise.prototype.catch

Attaches a callback function the rejection of the promise.

Syntax

catch(callback?)

Parameters

Return value

A Promise for the completion of the callback.

Examples

let p = new Promise((resolve, reject) => {
  reject(new Error("something happened"))
})
p.catch(error => print(error.message))
something happened