RSVP.Promise#catch()

catch (onRejection, label) Promise

Defined in bower_components/rsvp/lib/rsvp/promise.js:410

catch is simply sugar for then(undefined, onRejection) which makes it the same as the catch block of a try/catch statement.

function findAuthor(){
  throw new Error('couldn't find that author');
}

// synchronous
try {
  findAuthor();
} catch(reason) {
  // something went wrong
}

// async with promises
findAuthor().catch(function(reason){
  // something went wrong
});

Parameters:

onRejection Function
label String
optional string for labeling the promise. Useful for tooling.

Returns:

Promise
doc_EmberJs
2016-11-30 16:53:24
Comments
Leave a Comment

Please login to continue.