diff --git a/src/Tools/dotnet-gcdump/CommandLine/ConvertCommandHandler.cs b/src/Tools/dotnet-gcdump/CommandLine/ConvertCommandHandler.cs index ba40246f25..0a13b8b2ea 100644 --- a/src/Tools/dotnet-gcdump/CommandLine/ConvertCommandHandler.cs +++ b/src/Tools/dotnet-gcdump/CommandLine/ConvertCommandHandler.cs @@ -45,10 +45,20 @@ public static int ConvertFile(FileInfo input, string output, bool verbose) if (!EventPipeDotNetHeapDumper.DumpFromEventPipeFile(input.FullName, memoryGraph, log, heapInfo)) { + 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."); + return -1; + } + + try + { + memoryGraph.AllowReading(); + } + catch (ApplicationException ex) + { + 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."); return -1; } - memoryGraph.AllowReading(); GCHeapDump.WriteMemoryGraph(memoryGraph, outputFileInfo.FullName, "dotnet-gcdump"); return 0;