Skip to content

Commit

Permalink
Fetch resource string correctly (PowerShell#5114)
Browse files Browse the repository at this point in the history
  • Loading branch information
daxian-dbw authored and adityapatwardhan committed Oct 18, 2017
1 parent db6aec0 commit 2ceec72
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ private void UpdateTypeNames()
private ErrorRecord NewError(string errorId, string resourceId, object targetObject, params object[] args)
{
ErrorDetails details = new ErrorDetails(this.GetType().GetTypeInfo().Assembly,
"AddMember", resourceId, args);
"Microsoft.PowerShell.Commands.Utility.resources.AddMember", resourceId, args);
ErrorRecord errorRecord = new ErrorRecord(
new InvalidOperationException(details.Message),
errorId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,8 @@ private void AddSpaces(int numberOfSpacesToReturn, StringBuilder result)

private ErrorRecord NewError()
{
ErrorDetails details = new ErrorDetails(this.GetType().GetTypeInfo().Assembly,
"WebCmdletStrings", "JsonStringInBadFormat");
ErrorRecord errorRecord = new ErrorRecord(
new InvalidOperationException(details.Message),
new InvalidOperationException(WebCmdletStrings.JsonStringInBadFormat),
"JsonStringInBadFormat",
ErrorCategory.InvalidOperation,
InputObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,14 @@
$results = add-member -InputObject a 16 sp {1+1} -passthru
$results.sp | Should Be 2
}

It "Verify Add-Member error message is not empty" {
$object = @(1,2)
Add-Member -InputObject $object "ABC" "Value1"
Add-Member -InputObject $object "ABC" "Value2" -ErrorVariable errorVar -ErrorAction SilentlyContinue
$errorVar.Exception | Should BeOfType "System.InvalidOperationException"
$errorVar.Exception.Message | Should Not BeNullOrEmpty
}
}

Describe "Add-Member" -Tags "CI" {
Expand Down

0 comments on commit 2ceec72

Please sign in to comment.