JUL 20, 2012

Simple Rails Crash Reporting

Until now, the only way I knew how to trace of bugs in my Rails apps was using something like Airbrake or Exceptional. I’m usually far from cheap when it comes to web services, but provided that they at least show some design love (graphic but also information design; Gauges, Github, Heroku are all good examples). Since both Airbrake and Exceptional are in my opinion doing a terrible job at displaying the information I care about, I decided I wasn’t going to spend almost 100$/year on fugly crash reporting for my Rails apps.

So I came up with this simple custom crash reporting solution that simply sends the exceptions directly to my inbox (probably the sole feature I really need from an error reporting service)

Just put this code in any Rails controller for which you’d like to receive exception reports. The email will display the exception itself as the subject, and the message body will hold the first 10 lines of the backtrace. For actually sending the email, I use Mikel Lindsaar’s excellent Mail Ruby gem along with sendmail.

Until someone makes the Gauges of crash reporting, I’m going to stick to this simple solution of mine. If you think it could be improved in any way, shoot me an email or a tweet.

EDIT: many have pointed out the Exception Notifier Plugin for Rails, which is pretty much what I was looking for from the start.