Skip to content

Commit 1c46db3

Browse files
author
Scott Jungwirth
committed
Add 'catch' to Promise api
1 parent 7a707fd commit 1c46db3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/hello.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,8 @@ hello.utils.extend(hello.utils, {
936936

937937
/* provide optional information-hiding proxy */
938938
this.proxy = {
939-
then: this.then.bind(this)
939+
then: this.then.bind(this),
940+
catch: this.catch.bind(this)
940941
};
941942

942943
/* support optional executor function */
@@ -960,6 +961,9 @@ hello.utils.extend(hello.utils, {
960961
resolver(onRejected, next, "reject" )); /* [Promises/A+ 2.2.3/2.2.6] */
961962
execute(curr);
962963
return next.proxy; /* [Promises/A+ 2.2.7, 3.3] */
964+
},
965+
catch: function(onRejected) {
966+
return this.then(null, onRejected);
963967
}
964968
};
965969

0 commit comments

Comments
 (0)