Do not print stack trace if error reading crashReportJsonFile (#81467)
authorKunal Pathak <Kunal.Pathak@microsoft.com>
Fri, 3 Feb 2023 05:30:07 +0000 (21:30 -0800)
committerGitHub <noreply@github.com>
Fri, 3 Feb 2023 05:30:07 +0000 (21:30 -0800)
src/tests/Common/Coreclr.TestWrapper/CoreclrTestWrapperLib.cs

index 51af242..39078a5 100644 (file)
@@ -352,7 +352,16 @@ namespace CoreclrTestLib
             }
             outputWriter.WriteLine($"Printing stacktrace from '{crashReportJsonFile}'");
 
-            string contents = File.ReadAllText(crashReportJsonFile);
+            string contents;
+            try
+            {
+                contents = File.ReadAllText(crashReportJsonFile);
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine($"Error reading {crashReportJsonFile}: {ex.ToString()}");
+                return false;
+            }
             dynamic crashReport = JsonSerializer.Deserialize<JsonObject>(contents);
             var threads = crashReport["payload"]["threads"];