Index: src/promise.js |
diff --git a/src/promise.js b/src/promise.js |
index 27890a7626b37d12af837e73627617d6a94da4f2..f77fc5c197b982c19fea7253e1e7632d319e1d78 100644 |
--- a/src/promise.js |
+++ b/src/promise.js |
@@ -191,9 +191,22 @@ function PromiseHandle(value, handler, deferred) { |
%_CallFunction(result, deferred.resolve, deferred.reject, PromiseChain); |
else |
deferred.resolve(result); |
- } catch(e) { |
- // TODO(rossberg): perhaps log uncaught exceptions below. |
- try { deferred.reject(e) } catch(e) {} |
+ } catch (exception) { |
+ var uncaught = false; |
+ var reject_queue = GET_PRIVATE(deferred.promise, promiseOnReject); |
+ if (reject_queue && reject_queue.length == 0) { |
+ // The deferred promise may get a reject handler attached later. |
+ // For now, we consider the exception to be (for the moment) uncaught. |
+ uncaught = true; |
+ } |
+ try { |
+ deferred.reject(exception); |
+ } catch (e) { |
+ // The reject handler can only throw for a custom deferred promise. |
+ // We consider the original exception to be uncaught. |
+ uncaught = true; |
+ } |
+ if (uncaught) %DebugPendingExceptionInPromise(exception, deferred.promise); |
} |
} |