Skip to content

Commit

Permalink
fix: revert trace chain reversal (#970)
Browse files Browse the repository at this point in the history
  • Loading branch information
waltjones committed Jun 17, 2020
1 parent 7d0da9f commit 6089aa7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
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.unshift(trace_data(cause))
traces << trace_data(cause)
visited << cause
current_exception = cause
end
Expand Down
13 changes: 6 additions & 7 deletions spec/rollbar/item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,11 @@
body[:trace_chain].should be_kind_of(Array)

chain = body[:trace_chain]
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[0][:exception][:class].should match(/StandardError/)
chain[0][: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 @@ -475,8 +474,8 @@
it 'doesnt loop for ever' do
chain = payload['data'][:body][:trace_chain]

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

0 comments on commit 6089aa7

Please sign in to comment.