aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng/q.js
diff options
context:
space:
mode:
authorLucas Galfasó2014-01-31 15:22:36 -0300
committerCaitlin Potter2014-01-31 14:38:06 -0500
commit074b0675a1f97dce07f520f1ae6198ed3c604000 (patch)
tree04cf1ededc29a9de7eb37bbc6f8f306237b537ac /src/ng/q.js
parent5ed721b9b5e95ae08450e1ae9d5202e7f3f79295 (diff)
downloadangular.js-074b0675a1f97dce07f520f1ae6198ed3c604000.tar.bz2
fix($q): make $q.reject support `finally` and `catch`
Add support for the functions `finally` and `catch` to the promise returned by `$q.reject` Closes #6048 Closes #6076
Diffstat (limited to 'src/ng/q.js')
-rw-r--r--src/ng/q.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/ng/q.js b/src/ng/q.js
index 5c36dc07..0a98c335 100644
--- a/src/ng/q.js
+++ b/src/ng/q.js
@@ -223,7 +223,7 @@ function qFactory(nextTick, exceptionHandler) {
reject: function(reason) {
- deferred.resolve(reject(reason));
+ deferred.resolve(createInternalRejectedPromise(reason));
},
@@ -380,6 +380,12 @@ function qFactory(nextTick, exceptionHandler) {
* @returns {Promise} Returns a promise that was already resolved as rejected with the `reason`.
*/
var reject = function(reason) {
+ var result = defer();
+ result.reject(reason);
+ return result.promise;
+ };
+
+ var createInternalRejectedPromise = function(reason) {
return {
then: function(callback, errback) {
var result = defer();