From 423d6d9c49b9689ca7dadb9fa7ee14c59ff7b742 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 18 Sep 2023 23:36:14 -0700 Subject: [PATCH] Fix `Get-Service` non-terminating error message to include category (#20276) et-Service cmdlet has a common method for emitting non-terminating error message. Unfortunately, it assumed that if there isn't an inner exception message to just leave the content blank when formatting the error string. Fix here is that if there isn't an inner exception message, we use the string value of the error category instead of an empty string. --- .../commands/management/Service.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs index 1d007e6dac0..7f35e88a854 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs @@ -103,7 +103,7 @@ internal void WriteNonTerminatingError( string message = StringUtil.Format(errorMessage, serviceName, displayName, - (innerException == null) ? string.Empty : innerException.Message); + (innerException == null) ? category.ToString() : innerException.Message); var exception = new ServiceCommandException(message, innerException); exception.ServiceName = serviceName;