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

Unified Diff: corelib/src/implementation/future_implementation.dart

Issue 10542117: Allow optional callStack argument to Future.completeException(). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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
Index: corelib/src/implementation/future_implementation.dart
diff --git a/corelib/src/implementation/future_implementation.dart b/corelib/src/implementation/future_implementation.dart
index d77d0a98637db3df568bab5d1d0fc769c176b64f..08675a5212d8e2e05ebfc25859abe42651d11803 100644
--- a/corelib/src/implementation/future_implementation.dart
+++ b/corelib/src/implementation/future_implementation.dart
@@ -17,6 +17,11 @@ class FutureImpl<T> implements Future<T> {
Object _exception;
/**
+ * Call stack associated with [_exception], if one was provided.
+ */
+ var _callStack;
+
+ /**
* true, if any onException handler handled the exception.
*/
bool _exceptionHandled = false;
@@ -64,6 +69,13 @@ class FutureImpl<T> implements Future<T> {
return _exception;
}
+ get callStack() {
+ if (!isComplete) {
+ throw new FutureNotCompleteException();
+ }
+ return _callStack;
+ }
+
bool get isComplete() {
return _isComplete;
}
@@ -132,7 +144,7 @@ class FutureImpl<T> implements Future<T> {
try {
listener(this);
} catch (final e) {}
- }
+ }
}
}
@@ -144,15 +156,16 @@ class FutureImpl<T> implements Future<T> {
_complete();
}
- void _setException(var exception) {
+ void _setException(Object exception, Object callStack) {
if (exception === null) {
- // null is not a legal value for the exception of a Future
+ // null is not a legal value for the exception of a Future.
throw new IllegalArgumentException(null);
}
if (_isComplete) {
throw new FutureAlreadyCompleteException();
}
_exception = exception;
+ _callStack = callStack;
_complete();
}
@@ -166,8 +179,8 @@ class FutureImpl<T> implements Future<T> {
var transformed = null;
try {
transformed = transformation(v);
- } catch (final e) {
- completer.completeException(e);
+ } catch (final ex, final callStack) {
+ completer.completeException(ex, callStack);
return;
}
completer.complete(transformed);
@@ -185,8 +198,8 @@ class FutureImpl<T> implements Future<T> {
var future = null;
try {
future = transformation(v);
- } catch (final e) {
- completer.completeException(e);
+ } catch (final ex, final callStack) {
+ completer.completeException(ex, callStack);
return;
}
future.handleException((e) {
@@ -213,7 +226,7 @@ class CompleterImpl<T> implements Completer<T> {
_futureImpl._setValue(value);
}
- void completeException(var exception) {
- _futureImpl._setException(exception);
+ void completeException(Object exception, [Object callStack]) {
+ _futureImpl._setException(exception, callStack);
}
}

Powered by Google App Engine
This is Rietveld 408576698