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

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

Issue 11231024: Revert "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 Object stackTrace;
207
208 FutureUnhandledException(this.source, this.stackTrace);
209
210 String toString() {
211 return 'FutureUnhandledException: exception while executing Future\n '
212 '${source.toString().replaceAll("\n", "\n ")}\n'
213 'original stack trace:\n '
214 '${stackTrace.toString().replaceAll("\n","\n ")}';
215 }
216 }
217
218 196
219 /** 197 /**
220 * [Futures] holds additional utility functions that operate on [Future]s (for 198 * [Futures] holds additional utility functions that operate on [Future]s (for
221 * example, waiting for a collection of Futures to complete). 199 * example, waiting for a collection of Futures to complete).
222 */ 200 */
223 class Futures { 201 class Futures {
224 /** 202 /**
225 * Returns a future which will complete once all the futures in a list are 203 * Returns a future which will complete once all the futures in a list are
226 * complete. If any of the futures in the list completes with an exception, 204 * complete. If any of the futures in the list completes with an exception,
227 * the resulting future also completes with an exception. (The value of the 205 * the resulting future also completes with an exception. (The value of the
(...skipping 25 matching lines...) Expand all
253 future.handleException((exception) { 231 future.handleException((exception) {
254 if (!result.isComplete) { 232 if (!result.isComplete) {
255 completer.completeException(exception, future.stackTrace); 233 completer.completeException(exception, future.stackTrace);
256 } 234 }
257 return true; 235 return true;
258 }); 236 });
259 } 237 }
260 return result; 238 return result;
261 } 239 }
262 } 240 }
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