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

Unified Diff: sdk/lib/async/future.dart

Issue 2796363005: Fix bug in doWhile where it completes an error synchronously with an error. (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/async/future.dart
diff --git a/sdk/lib/async/future.dart b/sdk/lib/async/future.dart
index 25398426df6949709a6ace0d33d171cf283b6399..0368ae8220b162734c257fc8b8d7526e35440e2c 100644
--- a/sdk/lib/async/future.dart
+++ b/sdk/lib/async/future.dart
@@ -485,7 +485,9 @@ abstract class Future<T> {
try {
result = f();
} catch (error, stackTrace) {
- _completeWithErrorCallback(doneSignal, error, stackTrace);
+ // Cannot use _completeWithErrorCallback because it completes
+ // the future synchronously.
+ _asyncCompleteWithErrorCallback(doneSignal, error, stackTrace);
return;
}
if (result is Future<bool>) {
@@ -873,5 +875,15 @@ void _completeWithErrorCallback(_Future result, error, stackTrace) {
result._completeError(error, stackTrace);
}
+// Like [_completeWIthErrorCallback] but completes asynchronously.
eernst 2017/04/06 11:45:57 Typo: `WIth` --> `With`.
+void _asyncCompleteWithErrorCallback(_Future result, error, stackTrace) {
+ AsyncError replacement = Zone.current.errorCallback(error, stackTrace);
+ if (replacement != null) {
+ error = _nonNullError(replacement.error);
+ stackTrace = replacement.stackTrace;
+ }
+ result._asyncCompleteError(error, stackTrace);
+}
+
/** Helper function that converts `null` to a [NullThrownError]. */
Object _nonNullError(Object error) => error ?? new NullThrownError();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698