Skip to content

Commit 321950d

Browse files
JustinGroteandyleejordan
authored andcommitted
Handle PSArgumentOutOfRangeException when fetching variables
1 parent 871b468 commit 321950d

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/PowerShellEditorServices/Services/DebugAdapter/DebugService.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,8 +680,20 @@ private async Task<VariableContainerDetails> FetchVariableContainerAsync(string
680680
var scopeVariableContainer = new VariableContainerDetails(this.nextVariableId++, "Scope: " + scope);
681681
this.variables.Add(scopeVariableContainer);
682682

683-
IReadOnlyList<PSObject> results = await _executionService.ExecutePSCommandAsync<PSObject>(psCommand, CancellationToken.None)
684-
.ConfigureAwait(false);
683+
IReadOnlyList<PSObject> results;
684+
try
685+
{
686+
results = await _executionService.ExecutePSCommandAsync<PSObject>(psCommand, CancellationToken.None)
687+
.ConfigureAwait(false);
688+
}
689+
catch (CmdletInvocationException ex)
690+
{
691+
if (!ex.ErrorRecord.CategoryInfo.Reason.Equals("PSArgumentOutOfRangeException"))
692+
{
693+
throw;
694+
}
695+
results = null;
696+
}
685697

686698
if (results != null)
687699
{

0 commit comments

Comments
 (0)