FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Update Get-Error to not modify the original $Error object by SteveL-MSFT · Pull Request #11125 · PowerShell/PowerShell · GitHub

Update Get-Error to not modify the original $Error object - #11125

Merged
Ilya (iSazonov) merged 2 commits into
PowerShell:masterfrom
SteveL-MSFT:get-error-ets
Nov 21, 2019
Merged

Update Get-Error to not modify the original $Error object#11125
Ilya (iSazonov) merged 2 commits into
PowerShell:masterfrom
SteveL-MSFT:get-error-ets

Conversation

Steve Lee (SteveL-MSFT) commented Nov 19, 2019
edited
Loading

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Member Author

CodeFactor issue is by-design

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks good! Minor non-blocking comments only.

Nicely done! 😊

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Ilya (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
Ilya (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>

Copy link
Copy Markdown

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

Handy links:

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL