Powershell: Double "period" (..) in message for System.InvalidOperationException

Created on 26 Apr 2020  路  8Comments  路  Source: PowerShell/PowerShell


Not sure if this is classified as a bug, since it does not really affect functionality.

Steps to reproduce

try {Start-Process -FilePath "bogus.exe"} catch {Write-Host $PSItem.Exception.Message}

Expected behavior

(Only one period at end of sentence)
This command cannot be run due to the error: The system cannot find the file specified.

Actual behavior

(Two periods at end of sentence)
This command cannot be run due to the error: The system cannot find the file specified..

Environment data

Same results for both PS 7.0.0 and 7.1.0-preview.2 - I did not try preivew.1

Name                           Value
----                           -----
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0


Name                           Value
----                           -----
PSVersion                      7.1.0-preview.2
PSEdition                      Core
GitCommitId                    7.1.0-preview.2
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Area-Cmdlets-Management First-Time-Issue Issue-Enhancement Resolution-Fixed Up-for-Grabs

Most helpful comment

As @vexx32 said we can remove final dot at all in the resx file.

All 8 comments

Most likely a typo in the resx file that string is being pulled from. Should be a fairly simple fix, thanks for reporting it! 馃槉

The template is "This command cannot be run due to the error: {0}."
.Net message "The system cannot find the file specified."
After substitution we get two dots at end.
We could add single quotes...

I wonder if we can simply remove the period from the template string. A majority of error messages that it receives will have periods at the end anyway, no?

I don't see why removing the period from the template would break things. You are right that the majority of error messages are properly formatted, and really, I for one won't notice a missing period now and then.

All template strings in ProcessResources.resx end with dot.

@iSazonov why can't we trim it...

ex.Message.TrimEnd('.')

As @vexx32 said we can remove final dot at all in the resx file.

Thank you.

Was this page helpful?
0 / 5 - 0 ratings