Looking for Ruby on Rails development company?
Contact Us

How to customize airbrake subject in Ruby on Rails | Inkoop Blog

Airbrake tracks the 500 errors in an application and alerts developers about the error with backtrace and other details. We talk about how we can customize airbrake subject (in email and airbrake UI) to be more informative.

Posted by Ameena on 23 Jul 2018
How to customize airbrake subject in Ruby on Rails | Inkoop Blog

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


Looking for Ruby on Rails development company?
Contact Us

Related Services.



Hire ReactJS Developers
Hire Gatsby Developers
Hire NextJS Developers

We support the Open Source community.



Have a Project in mind?