Reporting handled errors

Reporting handled errors allows your application to recover from an error, while still reporting it to Bugsnag.

To notify Bugsnag of a handled exception you can call Bugsnag.notify:

  raise 'Something went wrong!'
rescue => e

Sending custom diagnostics

In order to quickly understand and fix some errors, it is often helpful to send additional diagnostic data which is specific to that error. Bugsnag.notify accepts a block which can alter the report before it is sent to Bugsnag.

Bugsnag.notify(exception) do |report|
  # Adjust the severity of this error
  report.severity = "warning"

  # Add customer information to this report
  report.add_tab(:account, {
    name: "Acme Co.",
    paying_customer: true

See the report object below for all available customization options.

The report object


Call add_tab on a report object to add a tab to the error report so that it would appear on your dashboard.

report.add_tab(:user_info, { name: })

The first parameter is the tab name that will appear in the error report and the second is the key, value list that will be displayed in the tab.


Set the project API key for the error report. The API key is normally set in the configuration, but it can be overridden to report to a different API key in some situations.

report.api_key = 'your-api-key-here'

Customize or filter breadcrumbs to be sent with the report. Modified breadcrumbs will not be validated again.

report.breadcrumbs.each { |breadcrumb| breadcrumb.meta_data = {} } # Clear the meta data


Set the context of the error report. This is notionally the location of the error and should be populated automatically. Context is displayed in the dashboard prominently.

report.context = 'billing'


Allows you to read the exceptions that will be combined into the report.

puts report.exceptions.first[:message] + ' found!'


Sets the grouping hash of the error report. All errors with the same grouping hash are grouped together. This is an advanced usage of the library and mis-using it will cause your errors not to group properly in your dashboard.

report.grouping_hash = report.exceptions.first[:message] + report.exceptions.first[:errorClass]


Calling ignore! on a report object will cause the report to not be sent to Bugsnag. This means that you can choose dynamically not to send an error depending on application state or the error itself.

report.ignore! if foo == 'bar'


Provides access to the meta_data in the error report.

report.ignore! if report.meta_data[:sidekiq][:retry_count] < 2


Removes a tab completely from the error report



Set the severity of the error. Severity can be error, warning or info.

report.severity = 'error'


Creates a hashed summary of the report. Given keys are :error_class, :severity, and optionally :message.

summary = report.summary
puts "#{summary[:error_class]} occurred with message: #{summary[:message]}"


You can set or read the user with the user property of the report.

report.user = {