Skip to content

Commit

Permalink
Rescue Rollbar::Notifier#process_payload and show error log message.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon de Andres committed Dec 18, 2014
1 parent ec8d9da commit a4d9c9a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/rollbar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ def process_payload(payload)
else
send_payload(payload)
end
rescue => e
log_error("[Rollbar] Error processing the payload: #{e.class}, #{e.message}. Payload: #{payload.inspect}")
report_internal_error(e)
end

private
Expand Down
15 changes: 15 additions & 0 deletions spec/rollbar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,21 @@ class DummyClass
end
end

describe '.process_payload' do
context 'if there is an exception sending the payload' do
let(:exception) { StandardError.new('error message') }
let(:payload) { { :foo => :bar } }

it 'logs the error and reports internal error' do
allow(Rollbar.notifier).to receive(:send_payload).and_raise(exception)
expect(Rollbar.notifier).to receive(:report_internal_error).with(exception)
expect(Rollbar.notifier).to receive(:log_error)

Rollbar.notifier.process_payload(payload)
end
end
end

# configure with some basic params
def configure
reconfigure_notifier
Expand Down

0 comments on commit a4d9c9a

Please sign in to comment.