Fix the error message when not a valid process ID is specified (#501)
authorSung Yoon Whang <suwhang@microsoft.com>
Wed, 25 Sep 2019 21:40:45 +0000 (14:40 -0700)
committerGitHub <noreply@github.com>
Wed, 25 Sep 2019 21:40:45 +0000 (14:40 -0700)
src/Tools/dotnet-counters/CounterMonitor.cs
src/Tools/dotnet-trace/CommandLine/Commands/CollectCommand.cs

index d7cf5ebbac3ff6622b6e8690dde8a269bfbe14bf..05b27465a3fb5c21b4049a965ebdda4337e06d7b 100644 (file)
@@ -145,7 +145,7 @@ namespace Microsoft.Diagnostics.Tools.Counters
         private async Task<int> StartMonitor()
         {
             if (_processId == 0) {
-                _console.Error.WriteLine("ProcessId is required.");
+                _console.Error.WriteLine("--process-id is required.");
                 return 1;
             }
 
index ca46abe1e9912d2762aa4377ff33e450fc9037be..dc93f1a9e0f531d5ea3b4bf395c4cc770bb2197c 100644 (file)
@@ -39,11 +39,16 @@ namespace Microsoft.Diagnostics.Tools.Trace
                 Debug.Assert(output != null);
                 Debug.Assert(profile != null);
                 Console.Clear();
-                if (processId <= 0)
+                if (processId < 0)
                 {
                     Console.Error.WriteLine("Process ID should not be negative.");
                     return ErrorCodes.ArgumentError;
                 }
+                else if (processId == 0)
+                {
+                    Console.Error.WriteLine("--process-id is required");
+                    return ErrorCodes.ArgumentError;
+                }
 
                 if (profile.Length == 0 && providers.Length == 0)
                 {