Il metodo catch() restituisce una Promise e si occusa esclusivamente nei casi respinti. Si comporta come una chiamata Promise.prototype.then(undefined, onRejected) (en-US).




p.catch(function(reason) {
   // rejection


Una Function chiamata quando la Promise viene respinta. Questa funzione richiede un parametro, la motivazione della respinta.


Il metodo catch può essere utile per gestire errori nella composizione delle promise.


Uso del metodo catch

var p1 = new Promise(function(resolve, reject) {

p1.then(function(value) {
  console.log(value); // "Success!"
  throw "oh, no!";
}).catch(function(e) {
  console.log(e); // "oh, no!"


Specification Status Comment
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'Promise.prototype.catch' in that specification.
Standard Initial definition in an ECMA standard.

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help! (en-US)

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 32 29.0 (29.0) [1] No support 19 7.1
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support No support 29.0 (29.0) [1] No support No support 8 32

[1] Gecko 24 has an experimental implementation of Promise, under the initial name of Future. It got renamed to its final name in Gecko 25, but disabled by default behind the flag dom.promise.enabled. Bug 918806 enabled Promises by default in Gecko 29.

See also