Skip to content

Commit b1cdb81

Browse files
authored
Handle empty frames case gracefully with local vars (#2807)
1 parent 6c0ac11 commit b1cdb81

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Unreleased
2+
3+
### Bug Fixes
4+
5+
- Handle empty frames case gracefully with local vars ([#2807](https://github.com/getsentry/sentry-ruby/pull/2807))
6+
17
## 6.2.0
28

39
### Features

sentry-ruby/lib/sentry/interfaces/single_exception.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def self.build_with_stacktrace(exception:, stacktrace_builder:, mechanism:)
6060
end
6161
end
6262

63-
stacktrace.frames.last.vars = locals
63+
stacktrace.frames.last&.vars = locals
6464
end
6565

6666
new(exception: exception, stacktrace: stacktrace, mechanism: mechanism)

sentry-ruby/spec/sentry_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,16 @@
310310
last_frame = event.dig(:exception, :values, 0, :stacktrace, :frames).last
311311
expect(last_frame[:vars]).to include({ a: "1", b: "0" })
312312
end
313+
314+
it 'does not throw SDK internal exception with empty frames' do
315+
expect do
316+
begin
317+
raise StandardError, 'Stuff', []
318+
rescue => e
319+
Sentry.capture_exception(e)
320+
end
321+
end.not_to raise_error
322+
end
313323
end
314324
end
315325

0 commit comments

Comments
 (0)