GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||
GeezerVison is showing github.com — Fetch resource string correctly by daxian-dbw · Pull Request #5114 · PowerShell/PowerShell Conversation
|
| "WebCmdletStrings", "JsonStringInBadFormat"); | ||
| ErrorRecord errorRecord = new ErrorRecord( | ||
| new InvalidOperationException(details.Message), | ||
| new InvalidOperationException(WebCmdletStrings.JsonStringInBadFormat), |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Is the change for the PR? I don't see a description and a test.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
If the resource file name and the resource string id is known/fixed, there is no point to use ResourceManager to retrieve the error message (which is what ErrorDetails does). Instead, we can just use the generated C# property.
The existence of the resource string is guaranteed by the build, so I didn't add a test for it.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I meant that the PR description mention only Add-Member cmdlet but not ConvertTo-Json.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Updated the description to include the ConvertTo-Json change.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The error string for this resource (WebCmdletStrings.JsonStringInBadFormat) doesn't seem right:
"The converted JSON string is in bad format."
I think this would be a better error message:
"The JSON string could not be converted because the format is incorrect."
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This code is from ConvertTo-Json cmdlet, which takes arbitrary objects and converts them to JSON string. The error message is used when it detects the JSON string we converted to is in bad format.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Please also update the WebCmdletStrings.JsonStringInBadFormat error string.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| "WebCmdletStrings", "JsonStringInBadFormat"); | ||
| ErrorRecord errorRecord = new ErrorRecord( | ||
| new InvalidOperationException(details.Message), | ||
| new InvalidOperationException(WebCmdletStrings.JsonStringInBadFormat), |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The error string for this resource (WebCmdletStrings.JsonStringInBadFormat) doesn't seem right:
"The converted JSON string is in bad format."
I think this would be a better error message:
"The JSON string could not be converted because the format is incorrect."
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.