Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The scope number '4' exceeds the number of active scopes. #2

Open
benh57 opened this issue Nov 3, 2018 · 2 comments
Open

The scope number '4' exceeds the number of active scopes. #2

benh57 opened this issue Nov 3, 2018 · 2 comments

Comments

@benh57
Copy link

benh57 commented Nov 3, 2018

Running the trap sample code on the main page produces this error. To fix i added a -1 in the for loop, but that may not be the proper fix.

Parameter name: scopeID
Actual value was 4.
At RavenPowerShell.psm1:138 char:39
+                 $scopeVariablesList = Get-Variable -Scope $i
+                                       ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-Variable], PSArgumentO
   utOfRangeException
    + FullyQualifiedErrorId : ArgumentOutOfRange,Microsoft.PowerShell.Commands
   .GetVariableCommand```
@imakiro
Copy link

imakiro commented Nov 20, 2019

Heyo ! I'm now encountering the same issue, do you mind telling me to which loop to added the -1 and how ?

@ghamed
Copy link

ghamed commented Dec 18, 2019

Ok so I was able to fix this. In order to fix it
file: "C:\Program Files\WindowsPowerShell\Modules\RavenPowerShell\1.1\RavenPowerShell.psm1"

Change line 136

for ($i = $callstackSkip; $i -lt ($callstackFrames.Count + $callstackSkip); $i++) {

to

for ($i = $callstackSkip; $i -lt ($callstackFrames.Count + $callstackSkip - 1); $i++) {

Testing (create a file from the following):

Import-Module RavenPowerShell -force

$ravenClient = New-RavenClient -SentryDsn 'https://SOMEENDPOINT'

trap {
    $ravenClient.CaptureException($_)
    break
}

$null[1000] = $true

Example

. .\test.ps1
Cannot index into a null array.
At C:\scripts\test.ps1:10 char:1
+ $null[1000] = $true
+ ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : NullArray

Above should now generate a new issue in sentry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants