fix($q): call reject() even if $exceptionHandler rethrows

Normally $exceptionHandler doesn't throw an exception.  It is normally
used just for logging and so on.  But if an application developer
implemented a version that did throw an exception then $q would never
have called reject() when converting an exception thrown inside a `then`
handler into a rejected promise.
This commit is contained in:
Pete Bacon Darwin
2013-07-31 10:09:23 +01:00
committed by Brian Ford
parent c197c2aa27
commit d59027c40e
2 changed files with 52 additions and 3 deletions

View File

@@ -215,8 +215,8 @@ function qFactory(nextTick, exceptionHandler) {
try {
result.resolve((callback || defaultCallback)(value));
} catch(e) {
exceptionHandler(e);
result.reject(e);
exceptionHandler(e);
}
};
@@ -224,8 +224,8 @@ function qFactory(nextTick, exceptionHandler) {
try {
result.resolve((errback || defaultErrback)(reason));
} catch(e) {
exceptionHandler(e);
result.reject(e);
exceptionHandler(e);
}
};