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

Apply trace chain in the correct order #916

Merged
merged 1 commit into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rollbar/item/backtrace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def trace_chain
current_exception = exception

while current_exception.respond_to?(:cause) && (cause = current_exception.cause) && cause.is_a?(Exception) && !visited.include?(cause)
traces << trace_data(cause)
traces.unshift(trace_data(cause))
visited << cause
current_exception = cause
end
Expand Down
13 changes: 7 additions & 6 deletions spec/rollbar/item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,12 @@
body[:trace_chain].should be_kind_of(Array)

chain = body[:trace_chain]
chain[0][:exception][:class].should match(/StandardError/)
chain[0][:exception][:message].should match(/the error/)
chain[0][:exception][:class].should match(/CauseException/)
chain[0][:exception][:message].should match(/the cause/)

chain[1][:exception][:class].should match(/StandardError/)
chain[1][:exception][:message].should match(/the error/)

chain[1][:exception][:class].should match(/CauseException/)
chain[1][:exception][:message].should match(/the cause/)
end

context 'when cause is not an Exception' do
Expand All @@ -458,8 +459,8 @@
it 'doesnt loop for ever' do
chain = payload['data'][:body][:trace_chain]

expect(chain[0][:exception][:message]).to be_eql('exception1')
expect(chain[1][:exception][:message]).to be_eql('exception2')
expect(chain[0][:exception][:message]).to be_eql('exception2')
expect(chain[1][:exception][:message]).to be_eql('exception1')
end
end
end
Expand Down