-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Open
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtimeWG-NeedsReviewNeeds a review by the labeled Working GroupNeeds a review by the labeled Working Group
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
The new-in-7.4 ErrorRecord.InvocationInfo.Statement property is designed to report the whole statement that triggered the error (possibly spanning multiple lines).
This doesn't work when the error was triggered by a command syntax error or by a parameter having been passed an invalid argument (in other words: the problem seems related to the parameter binder reporting the error):
try {
Get-Item -NoSuchParameter -LiteralPath .
}
catch {
'[' + $_.InvocationInfo.Statement + ']'
}Expected behavior
[Get-Item -NoSuchParameter -LiteralPath .]Actual behavior
[-NoSuchParameter]That is, only the offending parameter is reported.
This applies both to unrecognized parameters and known parameters having been given no argument.
If a known parameter is given an invalid argument, only that argument is reported.
Error details
No response
Environment data
PowerShell 7.4.0-rc.1Visuals
No response
Metadata
Metadata
Assignees
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtimeWG-NeedsReviewNeeds a review by the labeled Working GroupNeeds a review by the labeled Working Group