Reporting Errors

Use Honeybadger.notify(exception) to send any exception to Honeybadger. For example, to notify Honeybadger of a rescued exception without re-raising:

ruby
controller.rb
begin fail 'oops' rescue => exception Honeybadger.notify(exception) end

Reporting Errors Without an Exception

You can report any type of error to Honeybadger, not just exceptions. The simplest form is calling Honeybadger.notify with an error message:

ruby
Honeybadger.notify("Something is wrong here")

The error's class name will default to "Notice", and a backtrace will be generated for you from the location in your code where Honeybadger.notify was called.

Passing Additional Options to Honeybadger.notify

In some cases you will want to override the defaults or add additional information to your error reports. To do so, you can pass a second options Hash to Honeybadger.notify.

For example, building on the example in Reporting errors without an exception, you could override the default class name:

ruby
Honeybadger.notify("Something is wrong here", error_class: "MyError")

These are all the available options you can pass to Honeybadger.notify:

Option name Description Default value
:error_message The String error message. nil
:error_class The String class name of the error. "Notice"
:backtrace The Array backtrace of the error. caller
:fingerprint The String grouping fingerprint of the exception. nil
:force Always report the exception when true, even when ignored. false
:sync Send data synchronously (skips the worker) when true. false
:tags The String comma-separated list of tags. nil
:context The Hash context to associate with the exception. nil
:controller The String controller name (such as a Rails controller). nil
:action The String action name (such as a Rails controller action). nil
:parameters The Hash HTTP request paramaters. nil
:session The Hash HTTP request session. nil
:url The String HTTP request URL. nil

Getting the Current Backtrace

There are two ways to get the current backtrace in Ruby:

  1. Thread.current.backtrace returns the entire backtrace up to and including the current method.
  2. caller returns the backtrace up to but NOT including the current method.

Either method can be passed to Honeybadger.notify using the backtrace option. Honeybadger sends the exception backtrace by default, or caller if there is no exception object available.