Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ErrorRecord.InvocationInfo.Statement property doesn't report full statement for command syntax / invalid-argument errors #20638

Copy link
Copy link
@mklement0

Description

@mklement0
Issue body actions

Prerequisites

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.1

Visuals

No response

Reactions are currently unavailable

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

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.