diff --git a/lib/rollbar/item/backtrace.rb b/lib/rollbar/item/backtrace.rb index afc54283..a0f1ecae 100644 --- a/lib/rollbar/item/backtrace.rb +++ b/lib/rollbar/item/backtrace.rb @@ -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 diff --git a/spec/rollbar/item_spec.rb b/spec/rollbar/item_spec.rb index b2fa73e7..96acdb60 100644 --- a/spec/rollbar/item_spec.rb +++ b/spec/rollbar/item_spec.rb @@ -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 @@ -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