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

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: 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 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 184
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 (exception) {
195 // TODO(rossberg): perhaps log uncaught exceptions below. 195 var uncaught = false;
196 try { deferred.reject(e) } catch(e) {} 196 var reject_queue = GET_PRIVATE(deferred.promise, promiseOnReject);
197 if (reject_queue && reject_queue.length == 0) {
198 // The deferred promise may get a reject handler attached later.
199 // For now, we consider the exception to be (for the moment) uncaught.
200 uncaught = true;
201 }
202 try {
203 deferred.reject(exception);
204 } catch (e) {
205 // The reject handler can only throw for a custom deferred promise.
206 // We consider the original exception to be uncaught.
207 uncaught = true;
208 }
209 if (uncaught) %DebugPendingExceptionInPromise(exception, deferred.promise);
197 } 210 }
198 } 211 }
199 212
200 213
201 // Multi-unwrapped chaining with thenable coercion. 214 // Multi-unwrapped chaining with thenable coercion.
202 215
203 function PromiseThen(onResolve, onReject) { 216 function PromiseThen(onResolve, onReject) {
204 onResolve = 217 onResolve =
205 IS_NULL_OR_UNDEFINED(onResolve) ? PromiseIdResolveHandler : onResolve; 218 IS_NULL_OR_UNDEFINED(onResolve) ? PromiseIdResolveHandler : onResolve;
206 onReject = 219 onReject =
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 "resolve", PromiseCast 331 "resolve", PromiseCast
319 ]); 332 ]);
320 InstallFunctions($Promise.prototype, DONT_ENUM, [ 333 InstallFunctions($Promise.prototype, DONT_ENUM, [
321 "chain", PromiseChain, 334 "chain", PromiseChain,
322 "then", PromiseThen, 335 "then", PromiseThen,
323 "catch", PromiseCatch 336 "catch", PromiseCatch
324 ]); 337 ]);
325 } 338 }
326 339
327 SetUpPromise(); 340 SetUpPromise();
OLDNEW
« 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