Index: pkg/unittest/lib/src/core_matchers.dart |
diff --git a/pkg/unittest/lib/src/core_matchers.dart b/pkg/unittest/lib/src/core_matchers.dart |
index a9053a375cf3a18eeb35e0181d967d24a31af2d3..fbf146560db8ed7fdd1a30a5b2ff3d8ec0b602ca 100644 |
--- a/pkg/unittest/lib/src/core_matchers.dart |
+++ b/pkg/unittest/lib/src/core_matchers.dart |
@@ -290,13 +290,16 @@ class Throws extends BaseMatcher { |
done(() => expect(false, isTrue, reason: |
"Expected future to fail, but succeeded with '$value'.")); |
}, onError: (e) { |
- var reason; |
- if (e.stackTrace != null) { |
- var stackTrace = e.stackTrace.toString(); |
- stackTrace = " ${stackTrace.replaceAll("\n", "\n ")}"; |
- reason = "Actual exception trace:\n$stackTrace"; |
- } |
- done(() => expect(e.error, _matcher, reason: reason)); |
+ done(() { |
+ if (_matcher == null) return; |
+ var reason; |
+ if (e.stackTrace != null) { |
+ var stackTrace = e.stackTrace.toString(); |
+ stackTrace = " ${stackTrace.replaceAll("\n", "\n ")}"; |
+ reason = "Actual exception trace:\n$stackTrace"; |
+ } |
+ expect(e.error, _matcher, reason: reason); |
+ }); |
}); |
// It hasn't failed yet. |