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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/coreimpl/future_implementation.dart » ('j') | tests/corelib/future_test.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/core/future.dart
diff --git a/lib/core/future.dart b/lib/core/future.dart
index 99af2415180efcd019af18bce4ad6a7800ef087b..902432a64b90aa0a49be44957923cc0976fc79ea 100644
--- a/lib/core/future.dart
+++ b/lib/core/future.dart
@@ -193,6 +193,28 @@ class FutureAlreadyCompleteException implements Exception {
String toString() => "Exception: future already completed";
}
+/**
+ * Wraps unhandled exceptions provided to [Completer.completeException]. It is
+ * used to show both the error message and the stack trace for unhandled
+ * exceptions.
+ */
+class FutureUnhandledException implements Exception {
+ /** Wrapped exception. */
+ var source;
+
+ /** Trace for the wrapped exception. */
+ Object stackTrace;
+
+ FutureUnhandledException(this.source, this.stackTrace);
+
+ String toString() {
+ return 'FutureUnhandledException: exception while executing Future\n '
+ '${source.toString().replaceAll("\n", "\n ")}\n'
+ 'original stack trace:\n '
+ '${stackTrace.toString().replaceAll("\n","\n ")}';
+ }
+}
+
/**
* [Futures] holds additional utility functions that operate on [Future]s (for
« no previous file with comments | « no previous file | lib/coreimpl/future_implementation.dart » ('j') | tests/corelib/future_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698