|
1 | 1 | BeforeAll {
|
2 | 2 | . "$PSScriptRoot/utils.ps1"
|
3 | 3 | . "$PSScriptRoot/throwing.ps1"
|
| 4 | + . "$PSScriptRoot/throwingshort.ps1" |
4 | 5 | $events = [System.Collections.Generic.List[Sentry.SentryEvent]]::new();
|
5 | 6 | $transport = [RecordingTransport]::new()
|
6 | 7 | StartSentryForEventTests ([ref] $events) ([ref] $transport)
|
@@ -77,6 +78,31 @@ BeforeAll {
|
77 | 78 | # A module-based frame should be in-app=false
|
78 | 79 | $frames | Where-Object -Property Module | Select-Object -First 1 -ExpandProperty 'InApp' | Should -Be $false
|
79 | 80 | }
|
| 81 | + |
| 82 | + $checkShortErrorRecord = { |
| 83 | + $events.Count | Should -Be 1 |
| 84 | + [Sentry.SentryEvent]$event = $events.ToArray()[0] |
| 85 | + $event.SentryExceptions.Count | Should -Be 2 |
| 86 | + |
| 87 | + $event.SentryExceptions[1].Type | Should -Be 'Short context test' |
| 88 | + $event.SentryExceptions[1].Value | Should -Be 'Short context test' |
| 89 | + $event.SentryExceptions[1].Module | Should -BeNullOrEmpty |
| 90 | + [Sentry.SentryStackFrame[]] $frames = $event.SentryExceptions[1].Stacktrace.Frames |
| 91 | + $frames.Count | Should -BeGreaterThan 1 |
| 92 | + |
| 93 | + $frame = GetListItem $frames -1 |
| 94 | + |
| 95 | + $frame.Function | Should -Be "funcC" |
| 96 | + $frame.AbsolutePath | Should -Be (Join-Path $PSScriptRoot 'throwingshort.ps1') |
| 97 | + $frame.LineNumber | Should -BeGreaterThan 0 |
| 98 | + $frame.InApp | Should -Be $true |
| 99 | + |
| 100 | + $frame.PreContext | Should -Be @('function funcC {') |
| 101 | + $frame.PreContext.Count | Should -Be 1 |
| 102 | + $frame.ContextLine | Should -Be ' throw "Short context test"' |
| 103 | + $frame.PostContext | Should -Be @('}') |
| 104 | + $frame.PostContext.Count | Should -Be 1 |
| 105 | + } |
80 | 106 | }
|
81 | 107 |
|
82 | 108 | AfterAll {
|
@@ -119,6 +145,19 @@ Describe 'Out-Sentry' {
|
119 | 145 | @($null) | ForEach-Object $checkErrorRecord
|
120 | 146 | }
|
121 | 147 |
|
| 148 | + It 'captures short context' { |
| 149 | + try |
| 150 | + { |
| 151 | + funcC |
| 152 | + } |
| 153 | + catch |
| 154 | + { |
| 155 | + $_ | Out-Sentry |
| 156 | + } |
| 157 | + |
| 158 | + @($null) | ForEach-Object $checkShortErrorRecord |
| 159 | + } |
| 160 | + |
122 | 161 | It 'captures exception' {
|
123 | 162 | try
|
124 | 163 | {
|
|
0 commit comments