File tree 2 files changed +19
-1
lines changed
2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -235,7 +235,11 @@ class _FutureImpl<T> implements Future<T> {
235
235
completer.complete (result);
236
236
}
237
237
} catch (innerException, stackTrace) {
238
- completer.completeException (innerException, stackTrace);
238
+ if (identical (ex, innerException)) {
239
+ completer.completeException (innerException, this .stackTrace);
240
+ } else {
241
+ completer.completeException (innerException, stackTrace);
242
+ }
239
243
}
240
244
return false ;
241
245
});
Original file line number Diff line number Diff line change @@ -351,6 +351,19 @@ testCallStackIsCapturedIfChainCallbackThrows() {
351
351
Expect .isNotNull (chained.stackTrace);
352
352
}
353
353
354
+ testCallStackIsPreservedIfExceptionIsRethrownInTransformException () {
355
+ final completer = new Completer ();
356
+ var chained = completer.future.chain ((_) {
357
+ throw 'whoops!' ;
358
+ });
359
+ var transformed = chained.transformException ((e) {
360
+ throw e;
361
+ });
362
+
363
+ completer.complete ('blah' );
364
+ Expect .equals (transformed.stackTrace, chained.stackTrace);
365
+ }
366
+
354
367
// Tests for mixed usage of [onComplete], [then], and [handleException]
355
368
356
369
testCompleteWithCompletionAndSuccessHandlers () {
@@ -677,6 +690,7 @@ main() {
677
690
testCallStackReturnsCallstackPassedToCompleteException ();
678
691
testCallStackIsCapturedIfTransformCallbackThrows ();
679
692
testCallStackIsCapturedIfChainCallbackThrows ();
693
+ testCallStackIsPreservedIfExceptionIsRethrownInTransformException ();
680
694
testCompleteWithCompletionAndSuccessHandlers ();
681
695
testExceptionWithCompletionAndSuccessHandlers ();
682
696
testExceptionWithCompletionAndSuccessAndExceptionHandlers ();
You can’t perform that action at this time.
0 commit comments