Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/System.Management.Automation/engine/SessionStateScopeAPIs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ internal sealed partial class SessionStateInternal
/// </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>
Expand Down Expand Up @@ -92,18 +97,18 @@ internal SessionStateScope GetScopeByID(string scopeID)

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);
}
}
}
Expand Down Expand Up @@ -144,7 +149,7 @@ internal SessionStateScope GetScopeByID(int scopeID)
{
ArgumentOutOfRangeException outOfRange =
PSTraceSource.NewArgumentOutOfRangeException(
"scopeID",
ScopeParameterName,
originalID,
SessionStateStrings.ScopeIDExceedsAvailableScopes,
originalID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down