@@ -120,7 +120,7 @@ class StackTraceProcessor : SentryEventProcessor
120
120
{
121
121
$sentryFrames.Capacity = $this.StackTraceFrames.Count + 1
122
122
}
123
- else
123
+ elseif ( $null -ne $this .StackTraceString )
124
124
{
125
125
$sentryFrames.Capacity = $this.StackTraceString.Count + 1
126
126
}
@@ -139,7 +139,7 @@ class StackTraceProcessor : SentryEventProcessor
139
139
$sentryFrames.Add ($this.CreateFrame ($frame ))
140
140
}
141
141
}
142
- else
142
+ elseif ( $null -ne $this .StackTraceString )
143
143
{
144
144
# Note: if InvocationInfo is present, use it to update:
145
145
# - the first frame (in case of `$_ | Out-Sentry` in a catch clause).
@@ -177,7 +177,7 @@ class StackTraceProcessor : SentryEventProcessor
177
177
{
178
178
# Update module info
179
179
$this.SetModule ($sentryFrame )
180
- $sentryFrame.InApp = $null -eq $ sentryFrame.Module
180
+ $sentryFrame.InApp = [ string ]::IsNullOrEmpty( $ sentryFrame.Module )
181
181
$this.SetContextLines ($sentryFrame )
182
182
}
183
183
@@ -210,7 +210,7 @@ class StackTraceProcessor : SentryEventProcessor
210
210
{
211
211
$sentryFrame = [Sentry.SentryStackFrame ]::new()
212
212
# at funcB, C:\dev\sentry-powershell\tests\capture.tests.ps1: line 363
213
- $regex = ' at (?<Function>[^,]+ ), (?<AbsolutePath>.+ ): line (?<LineNumber>\d+ )'
213
+ $regex = ' at (?<Function>[^,]* ), (?<AbsolutePath>.* ): line (?<LineNumber>\d* )'
214
214
if ($frame -match $regex )
215
215
{
216
216
$sentryFrame.AbsolutePath = $Matches.AbsolutePath
@@ -226,12 +226,12 @@ class StackTraceProcessor : SentryEventProcessor
226
226
227
227
hidden SetScriptInfo([Sentry.SentryStackFrame ] $sentryFrame , [System.Management.Automation.CallStackFrame ] $frame )
228
228
{
229
- if ($null -ne $ frame.ScriptName )
229
+ if (! [ string ]::IsNullOrEmpty( $ frame.ScriptName ) )
230
230
{
231
231
$sentryFrame.AbsolutePath = $frame.ScriptName
232
232
$sentryFrame.LineNumber = $frame.ScriptLineNumber
233
233
}
234
- elseif ($null -ne $ frame.Position -and $null -ne $ frame.Position.File )
234
+ elseif (! [ string ]::IsNullOrEmpty( $ frame.Position ) -and ! [ string ]::IsNullOrEmpty( $ frame.Position.File ) )
235
235
{
236
236
$sentryFrame.AbsolutePath = $frame.Position.File
237
237
$sentryFrame.LineNumber = $frame.Position.StartLineNumber
@@ -241,7 +241,7 @@ class StackTraceProcessor : SentryEventProcessor
241
241
242
242
hidden SetModule([Sentry.SentryStackFrame ] $sentryFrame )
243
243
{
244
- if ($null -ne $ sentryFrame.AbsolutePath )
244
+ if (! [ string ]::IsNullOrEmpty( $ sentryFrame.AbsolutePath ) )
245
245
{
246
246
if ($prefix = $this.modulePaths | Where-Object { $sentryFrame.AbsolutePath.StartsWith ($_ ) })
247
247
{
@@ -265,7 +265,7 @@ class StackTraceProcessor : SentryEventProcessor
265
265
266
266
hidden SetFunction([Sentry.SentryStackFrame ] $sentryFrame , [System.Management.Automation.CallStackFrame ] $frame )
267
267
{
268
- if ($null -eq $ sentryFrame.AbsolutePath -and $frame.FunctionName -eq ' <ScriptBlock>' -and $null -ne $ frame.Position )
268
+ if ([ string ]::IsNullOrEmpty( $ sentryFrame.AbsolutePath ) -and $frame.FunctionName -eq ' <ScriptBlock>' -and ! [ string ]::IsNullOrEmpty( $ frame.Position ) )
269
269
{
270
270
$sentryFrame.Function = $frame.Position.Text
271
271
}
@@ -277,7 +277,12 @@ class StackTraceProcessor : SentryEventProcessor
277
277
278
278
hidden SetContextLines([Sentry.SentryStackFrame ] $sentryFrame )
279
279
{
280
- if ($null -ne $sentryFrame.AbsolutePath -and $sentryFrame.LineNumber -ge 1 -and (Test-Path $sentryFrame.AbsolutePath - PathType Leaf))
280
+ if ([string ]::IsNullOrEmpty($sentryFrame.AbsolutePath ) -or $sentryFrame.LineNumber -lt 1 )
281
+ {
282
+ return
283
+ }
284
+
285
+ if ((Test-Path $sentryFrame.AbsolutePath - IsValid) -and (Test-Path $sentryFrame.AbsolutePath - PathType Leaf))
281
286
{
282
287
try
283
288
{
0 commit comments