mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix parameter name in the Get-Variable cmdlet error message. (#7384)
Before the fix when using Get-Variable or Get-Alias cmdlets with the -Scope parameter with wrong value, the error message refers to 'scopeID' parameter instead of 'Scope'.
This commit is contained in:
@@ -21,6 +21,11 @@ namespace System.Management.Automation
|
||||
/// </summary>
|
||||
private SessionStateScope _currentScope;
|
||||
|
||||
/// <summary>
|
||||
/// Cmdlet parameter name to return in the error message instead of "scopeID".
|
||||
/// </summary>
|
||||
internal const string ScopeParameterName = "Scope";
|
||||
|
||||
/// <summary>
|
||||
/// Given a scope identifier, returns the proper session state scope.
|
||||
/// </summary>
|
||||
@@ -92,18 +97,18 @@ namespace System.Management.Automation
|
||||
|
||||
if (scopeNumericID < 0)
|
||||
{
|
||||
throw PSTraceSource.NewArgumentOutOfRangeException("scopeID", scopeID);
|
||||
throw PSTraceSource.NewArgumentOutOfRangeException(ScopeParameterName, scopeID);
|
||||
}
|
||||
|
||||
result = GetScopeByID(scopeNumericID) ?? _currentScope;
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
throw PSTraceSource.NewArgumentException("scopeID", AutomationExceptions.InvalidScopeIdArgument, "scopeID");
|
||||
throw PSTraceSource.NewArgumentException(ScopeParameterName, AutomationExceptions.InvalidScopeIdArgument, ScopeParameterName);
|
||||
}
|
||||
catch (OverflowException)
|
||||
{
|
||||
throw PSTraceSource.NewArgumentOutOfRangeException("scopeID", scopeID);
|
||||
throw PSTraceSource.NewArgumentOutOfRangeException(ScopeParameterName, scopeID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,7 +149,7 @@ namespace System.Management.Automation
|
||||
{
|
||||
ArgumentOutOfRangeException outOfRange =
|
||||
PSTraceSource.NewArgumentOutOfRangeException(
|
||||
"scopeID",
|
||||
ScopeParameterName,
|
||||
originalID,
|
||||
SessionStateStrings.ScopeIDExceedsAvailableScopes,
|
||||
originalID);
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
<value>Cannot process argument because the value of argument "{0}" is not valid. Change the value of the "{0}" argument and run the operation again.</value>
|
||||
</data>
|
||||
<data name="InvalidScopeIdArgument" xml:space="preserve">
|
||||
<value>Cannot process argument because the value of argument "{0}" is not valid. Valid values are "Global", "Local", or "Script", or a number relative to the current scope (0 through the number of scopes where 0 is the current scope and 1 is its parent). Change the value of the "{0}" argument and run the operation again.</value>
|
||||
<value>Cannot process argument because the value of parameter "{0}" is not valid. Valid values are "Global", "Local", or "Script", or a number relative to the current scope (0 through the number of scopes where 0 is the current scope and 1 is its parent). Change the value of the "{0}" parameter and run the operation again.</value>
|
||||
</data>
|
||||
<data name="ArgumentNull" xml:space="preserve">
|
||||
<value>Cannot process argument because the value of argument "{0}" is null. Change the value of argument "{0}" to a non-null value.</value>
|
||||
|
||||
Reference in New Issue
Block a user