Commit 00aa6bb5 authored by Stefan Penner's avatar Stefan Penner

Merge pull request #101 from twokul/promise#fail

adding promise#fail
parents da80daf2 16f95c05
......@@ -136,6 +136,17 @@ getJSON("/post/1.json").then(function(post) {
});
```
You can also use `fail` for error handling, which is a shortcut for
`then(null, rejection)`, like so:
```javascript
getJSON("/post/1.json").then(function(post) {
return getJSON(post.commentURL);
}).fail(function(error) {
// handle errors
});
```
## Arrays of promises
Sometimes you might want to work with many promises at once. If you
......
......@@ -120,6 +120,10 @@ Promise.prototype = {
});
return thenPromise;
},
fail: function(fail) {
return this.then(null, fail);
}
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment