diff --git a/pkg/front_end/lib/src/fasta/crash.dart b/pkg/front_end/lib/src/fasta/crash.dart index 11f22c84ec3..17e1cc23e34 100644 --- a/pkg/front_end/lib/src/fasta/crash.dart +++ b/pkg/front_end/lib/src/fasta/crash.dart @@ -32,6 +32,8 @@ class Crash { final StackTrace? trace; + bool _hasBeenReported = false; + Crash(this.uri, this.charOffset, this.error, this.trace); @override @@ -70,6 +72,7 @@ Future reportCrash(error, StackTrace trace, trace = error.trace ?? trace; uri = error.uri ?? uri; charOffset = error.charOffset ?? charOffset; + error._hasBeenReported = true; error = error.error; } uri ??= firstSourceUri; @@ -92,7 +95,8 @@ Future reportCrash(error, StackTrace trace, // Assume the crash logger isn't running. client.close(force: true); return new Future.error( - new Crash(uri, charOffset, error, trace), trace); + new Crash(uri, charOffset, error, trace).._hasBeenReported = true, + trace); } // ignore: unnecessary_null_comparison if (request != null) { @@ -130,11 +134,12 @@ Future withCrashReporting( resetCrashReporting(); try { return await action(); - } on Crash { - rethrow; } on DebugAbort { rethrow; } catch (e, s) { + if (e is Crash && e._hasBeenReported) { + rethrow; + } UriOffset? uriOffset = currentUriOffset(); return reportCrash(e, s, uriOffset?.uri, uriOffset?.fileOffset); }