How to customize airbrake subject (in Email and Airbrake UI) in Ruby on Rails

Well, if you have come to this page then you should be knowing how important is issue tracker in developer’s life. The tracker that i am addressing today is Airbrake.

Airbrake gives you pretty clear description about the error. But, what if you want extra information to be added in the subject of the error.

# application_controller.rb

...
if Rails.env.production?
  rescue_from StandardError, with: :handle_exception
end

def handle_exception exception
  exception.message << "---- Add your custom message here --------"
  notify_airbrake(exception)
end

...

notify_airbrake should be used for sending manual notifications and make sure you are calling it when you are still inside the controller else it works same as Airbrake.notify.

In the UI, the status still remains 200 which is bad. So, the fix is:

# application_controller.rb

...
def handle_exception exception
  exception.message << "---- Add your custom message here --------"
  notify_airbrake(exception)
  render :file => 'public/500.html', :status => 500, :layout => false
end

Keep Coding !!!

Ameena



What do we do?


We work on website development using Ruby on Rails, NodeJS, ReactJS, AngularJS. View all the services we provide here.


Say Hello! See our work