Fetch resource string correctly (#5114)
This commit is contained in:
parent
db6aec0850
commit
2ceec725f6
|
@ -514,7 +514,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
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,
|
||||
|
|
|
@ -381,10 +381,8 @@ namespace Microsoft.PowerShell.Commands
|
|||
|
||||
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);
|
||||
|
|
|
@ -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" {
|
||||
|
|
Loading…
Reference in a new issue