Skip to content

Sending notices to Airbrake manually from controllers

shime edited this page Oct 27, 2012 · 3 revisions

For the most part, Airbrake works for itself.

It intercepts the exception middleware calls, sends notifications and continues the middleware call chain.

If you want to log arbitrary things which you've rescued yourself from a controller, you can do something like this inside actions:

   # ...
   rescue => ex
     notify_airbrake(ex)
     flash[:failure] = 'Encryptions could not be rerouted, try again.'
   end

The #notify_airbrake call will send the notice over to Airbrake for later analysis. While in your controllers you use the notify_airbrake method, anywhere else in your code, use Airbrake.notify.

To perform custom error processing after Airbrake has been notified, define the instance method #rescue_action_in_public_without_airbrake(exception) in your controller.