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

Side by Side Diff: lib/core/future.dart

Issue 11225017: Improvement on future: add stack trace to future failures. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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
« no previous file with comments | « no previous file | lib/coreimpl/future_implementation.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * A [Future] is used to obtain a value sometime in the future. Receivers of a 6 * A [Future] is used to obtain a value sometime in the future. Receivers of a
7 * [Future] can obtain the value by passing a callback to [then]. For example: 7 * [Future] can obtain the value by passing a callback to [then]. For example:
8 * 8 *
9 * Future<int> future = getFutureFromSomewhere(); 9 * Future<int> future = getFutureFromSomewhere();
10 * future.then((value) { 10 * future.then((value) {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 186
187 /** 187 /**
188 * Thrown if a completer tries to set the value on a future that is already 188 * Thrown if a completer tries to set the value on a future that is already
189 * complete. 189 * complete.
190 */ 190 */
191 class FutureAlreadyCompleteException implements Exception { 191 class FutureAlreadyCompleteException implements Exception {
192 FutureAlreadyCompleteException() {} 192 FutureAlreadyCompleteException() {}
193 String toString() => "Exception: future already completed"; 193 String toString() => "Exception: future already completed";
194 } 194 }
195 195
196 /**
197 * Wraps unhandled exceptions provided to [Completer.completeException]. It is
198 * used to show both the error message and the stack trace for unhandled
199 * exceptions.
200 */
201 class FutureUnhandledException implements Exception {
202 /** Wrapped exception. */
203 var source;
204
205 /** Trace for the wrapped exception. */
206 var stackTrace;
207
208 FutureUnhandledException(this.source, this.stackTrace);
Jennifer Messerly 2012/10/19 23:54:15 nit: newline after this
209 String toString() => "$source\n$stackTrace".replaceAll('\n','\n ');
Jennifer Messerly 2012/10/19 23:54:15 include more context here? maybe something like:
210 }
211
196 212
197 /** 213 /**
198 * [Futures] holds additional utility functions that operate on [Future]s (for 214 * [Futures] holds additional utility functions that operate on [Future]s (for
199 * example, waiting for a collection of Futures to complete). 215 * example, waiting for a collection of Futures to complete).
200 */ 216 */
201 class Futures { 217 class Futures {
202 /** 218 /**
203 * Returns a future which will complete once all the futures in a list are 219 * Returns a future which will complete once all the futures in a list are
204 * complete. If any of the futures in the list completes with an exception, 220 * complete. If any of the futures in the list completes with an exception,
205 * the resulting future also completes with an exception. (The value of the 221 * the resulting future also completes with an exception. (The value of the
(...skipping 25 matching lines...) Expand all
231 future.handleException((exception) { 247 future.handleException((exception) {
232 if (!result.isComplete) { 248 if (!result.isComplete) {
233 completer.completeException(exception, future.stackTrace); 249 completer.completeException(exception, future.stackTrace);
234 } 250 }
235 return true; 251 return true;
236 }); 252 });
237 } 253 }
238 return result; 254 return result;
239 } 255 }
240 } 256 }
OLDNEW
« no previous file with comments | « no previous file | lib/coreimpl/future_implementation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698