Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1225)

Unified Diff: src/promise.js

Issue 249503002: Trigger debug event on not yet caught exception in promises. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: always use original exception Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/debug-debugger.js ('K') | « src/isolate.cc ('k') | src/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« src/debug-debugger.js ('K') | « src/isolate.cc ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698