Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

If no rejectCallback is specified, add a standard callback that simpl…

…y rethrows the error.

This way the internal deferred is handled (i.e. no uncaught exception will be thrown). We return a new deferred anyway, so error handling is done on that deferred, or if it isn't, an uncaught exception will be thrown.
  • Loading branch information...
commit b82d8a0c7424e1c3ecfbece329707b7435323406 1 parent 498ac69
@novemberborn novemberborn authored
Showing with 3 additions and 0 deletions.
  1. +3 −0  lib/promise.js
View
3  lib/promise.js
@@ -295,6 +295,8 @@ function perform(value, async, sync){
/**
* Promise manager to make it easier to consume promises
*/
+
+function rethrow(err){ throw err; }
/**
* Registers an observer on a promise.
@@ -312,6 +314,7 @@ exports.whenPromise = function(value, resolvedCallback, rejectCallback, progress
},function(error){
deferred.reject(error);
});
+ rejectCallback = rejectCallback || rethrow;
}else{
deferred.resolve(value);
}
Please sign in to comment.
Something went wrong with that request. Please try again.