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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 function PromiseHandle(value, handler, deferred) { 185 function PromiseHandle(value, handler, deferred) {
186 try { 186 try {
187 var result = handler(value); 187 var result = handler(value);
188 if (result === deferred.promise) 188 if (result === deferred.promise)
189 throw MakeTypeError('promise_cyclic', [result]); 189 throw MakeTypeError('promise_cyclic', [result]);
190 else if (IsPromise(result)) 190 else if (IsPromise(result))
191 %_CallFunction(result, deferred.resolve, deferred.reject, PromiseChain); 191 %_CallFunction(result, deferred.resolve, deferred.reject, PromiseChain);
192 else 192 else
193 deferred.resolve(result); 193 deferred.resolve(result);
194 } catch(e) { 194 } catch(e) {
195 // TODO(rossberg): perhaps log uncaught exceptions below. 195 if (GET_PRIVATE(promise, promiseOnReject).length == 0) {
196 try { deferred.reject(e) } catch(e) {} 196 // There is no reject handler defined (yet). The debugger should know.
197 %DebugPendingExceptionInPromise(e, promise);
198 }
199 try { deferred.reject(e) } catch(e) {
200 // Reject handler threw (must be a custom one).
rossberg 2014/04/24 07:27:36 "must have been"
201 %DebugPendingExceptionInPromise(e, promise);
202 }
197 } 203 }
198 } 204 }
199 205
200 206
201 // Multi-unwrapped chaining with thenable coercion. 207 // Multi-unwrapped chaining with thenable coercion.
202 208
203 function PromiseThen(onResolve, onReject) { 209 function PromiseThen(onResolve, onReject) {
204 onResolve = 210 onResolve =
205 IS_NULL_OR_UNDEFINED(onResolve) ? PromiseIdResolveHandler : onResolve; 211 IS_NULL_OR_UNDEFINED(onResolve) ? PromiseIdResolveHandler : onResolve;
206 onReject = 212 onReject =
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 "resolve", PromiseCast 324 "resolve", PromiseCast
319 ]); 325 ]);
320 InstallFunctions($Promise.prototype, DONT_ENUM, [ 326 InstallFunctions($Promise.prototype, DONT_ENUM, [
321 "chain", PromiseChain, 327 "chain", PromiseChain,
322 "then", PromiseThen, 328 "then", PromiseThen,
323 "catch", PromiseCatch 329 "catch", PromiseCatch
324 ]); 330 ]);
325 } 331 }
326 332
327 SetUpPromise(); 333 SetUpPromise();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698