Skip to content


Subversion checkout URL

You can clone with
Download ZIP

Using Airbrake with plain Ruby

Morgan Mikel McDaris edited this page · 7 revisions

You can also pass a hash to Airbrake.notify_or_ignore method and store whatever you want, not just an exception. And you can also use it anywhere, not just in controllers:

Airbrake.configure do |config|
  config.api_key = '1234deadbeef...'

  params = {
     # params that you pass to a method that can throw an exception
rescue => e
   parameters: params,
   cgi_data: ENV.to_hash

While in your controllers you use the notify_airbrake method, anywhere else in your code, use Airbrake.notify_or_ignore. Airbrake will get all the information about the error itself. As for a hash, these are the keys you should pass:

  • :error_class - Use this to group similar errors together. When Airbrake catches an exception it sends the class name of that exception object.
  • :error_message - This is the title of the error you see in the errors list. For exceptions it is "#{}: #{exception.message}"
  • :parameters - While there are several ways to send additional data to Airbrake, passing a Hash as :parameters as in the example above is the most common use case. When Airbrake catches an exception in a controller, the actual HTTP client request parameters are sent using this key.

Airbrake merges the hash you pass with these default options:

  api_key:       Airbrake.api_key,
  error_message: 'Notification',
  backtrace:     caller,
  parameters:    {},
  session:       {}

You can override any of those parameters.

Sending shell environment variables

One common request we see is to send shell environment variables along with manual exception notification. We recommend sending them along with CGI data (:cgi_data).

See Airbrake::Notice#initialize in lib/airbrake/notice.rb for more details.

Something went wrong with that request. Please try again.