Skip to content

Commit 7b2a66d

Browse files
authored
Produce better error messages in gcdump convert command (#5814)
1 parent aee7d82 commit 7b2a66d

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/Tools/dotnet-gcdump/CommandLine/ConvertCommandHandler.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,20 @@ public static int ConvertFile(FileInfo input, string output, bool verbose)
4545

4646
if (!EventPipeDotNetHeapDumper.DumpFromEventPipeFile(input.FullName, memoryGraph, log, heapInfo))
4747
{
48+
Console.Error.WriteLine($"Failed to convert '{input.FullName}' to gcdump. The input file may not be a valid nettrace file, or it may not contain GC heap events. Try running with '-v' for more information.");
49+
return -1;
50+
}
51+
52+
try
53+
{
54+
memoryGraph.AllowReading();
55+
}
56+
catch (ApplicationException ex)
57+
{
58+
Console.Error.WriteLine($"Failed to convert '{input.FullName}': {ex.Message} The nettrace file may not contain a complete GC heap dump. Try running with '-v' for more information.");
4859
return -1;
4960
}
5061

51-
memoryGraph.AllowReading();
5262
GCHeapDump.WriteMemoryGraph(memoryGraph, outputFileInfo.FullName, "dotnet-gcdump");
5363

5464
return 0;

0 commit comments

Comments
 (0)