Use runZonedGuarded
diff --git a/pkgs/test_reflective_loader/lib/test_reflective_loader.dart b/pkgs/test_reflective_loader/lib/test_reflective_loader.dart
index 71d4366..cfd738d 100644
--- a/pkgs/test_reflective_loader/lib/test_reflective_loader.dart
+++ b/pkgs/test_reflective_loader/lib/test_reflective_loader.dart
@@ -249,9 +249,9 @@
* - The test returns a future which completes with an error.
* - An exception is thrown to the zone handler from a timer task.
*/
-Future<Object?> _runFailingTest(ClassMirror classMirror, Symbol symbol) {
+Future<Object?>? _runFailingTest(ClassMirror classMirror, Symbol symbol) {
bool passed = false;
- return runZoned(() {
+ return runZonedGuarded(() {
return new Future.sync(() => _runTest(classMirror, symbol)).then((_) {
passed = true;
test_package.fail('Test passed - expected to fail.');
@@ -262,7 +262,7 @@
}
// otherwise, an exception is not a failure for _runFailingTest
});
- }, onError: (e) {
+ }, (e, st) {
// if passed, and we call fail(), rethrow this exception
if (passed) {
throw e;