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

Deliver even when an error raised in the block argument #660

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 5 additions & 1 deletion lib/bugsnag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ def notify(exception, auto_notify=false, &block)

# If this is not an auto_notify then the block was provided by the user. This should be the last
# block that is run as it is the users "most specific" block.
yield(report) if block_given? && !auto_notify
begin
yield(report) if block_given? && !auto_notify
rescue => e
report.add_tab(:report_error, "Failed to report block (#{e.class}): #{e.message} \n#{e.backtrace[0..9].join("\n")}")
end

if report.ignore?
configuration.debug("Not notifying #{report.exceptions.last[:errorClass]} due to ignore being signified in user provided block")
Expand Down
10 changes: 10 additions & 0 deletions spec/bugsnag_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@
})
expect(breadcrumb.timestamp).to be_within(1).of(sent_time)
end

it 'is also be delivered when an error raised in the block argument' do
Bugsnag.notify('It crashed') do |report|
repor.context = 'test'
end
expect(Bugsnag).to have_sent_notification{ |payload, headers|
event = get_event_from_payload(payload)
expect(event['metaData']['custom']['report_error']).to match(/Failed to report block \(NameError\): undefined local variable or method/)
}
end
end

describe '#configure' do
Expand Down