-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Make exception errors in PowerShell able to associate with the right history entry #19095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@SteveL-MSFT I have addressed your feedback. Please take another look, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! One optional suggestion
Co-authored-by: Patrick Meinecke <[email protected]>
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
🎉 Handy links: |
PR Summary
Make errors in PowerShell able to associate with the right history entry, by adjusting the
HistoryId
property of theInvocationInfo
of anErrorRecord
.PR Context
ErrorRecord.InvocationInfo.HistoryId
should point to the history entry which contains the command-line that triggered the error. This is true for errors stemmed fromWrite-Error
,$PSCmdlet.WriteError
,$PSCmdlet.ThrowTerminatingError
, and parameter binding failures.However, it's not the case for errors stemmed from
throw
statement and other exceptions, such as1/0
or method call exceptions. For those exceptions, theHistoryId
turns out to be-1
, which cannot be used to associate with the command from history that triggered the exception. This becomes a problem to the feedback provider feature we are working on, which needs to reliably tell if an error is resulted by the command that was just done execution.This PR is to address this issue, to make errors stemmed from exceptions also points to the right history command that triggered the exception.
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.