8000 Update Get-Error to not modify the original $Error object by SteveL-MSFT · Pull Request #11125 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@SteveL-MSFT
Copy link
Member
@SteveL-MSFT SteveL-MSFT commented Nov 19, 2019

PR Summary

Get-Error currently modifies the original $Error object specifically the pstypenames. Fix is to use an overload when constructing the PSObject to copy it.

PR Context

Fix #11122

PR Checklist

@SteveL-MSFT
Copy link
Member Author

CodeFactor issue is by-design

Copy link
Collaborator
@vexx32 vexx32 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Minor non-blocking comments only.

Nicely done! 😊

Comment on lines +113 to +117
try {
1 / 0
}
catch {
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it doesn't really matter, but is there a reason you didn't just use Write-Error for this purpose? 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't consider that and this was the first thing I thought of. At least now it's consistent within the test script :)

Although I also learned later that you can just write to $Error anyways.

@iSazonov iSazonov added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Nov 20, 2019
@iSazonov iSazonov added this to the 7.0.0-preview.6 milestone Nov 20, 2019
…-Error.cs

Co-Authored-By: Joel Sallow (/u/ta11ow) <32407840+vexx32@users.noreply.github.com>
@iSazonov iSazonov merged commit 0aaced3 into PowerShell:master Nov 21, 2019
@SteveL-MSFT SteveL-MSFT deleted the get-error-ets branch December 2, 2019 17:23
@daxian-dbw daxian-dbw modified the milestones: GA-approved, 7.0.0-rc.2 Jan 11, 2020
@ghost
Copy link
ghost commented Jan 16, 2020

🎉v7.0.0-rc.2 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get-Error unexpectedly modifies the ETS type names of the ErrorRecord instances it processes in place

4 participants

0