Fun with Exception Notifier

August 1st, 2007

Fun? Perhaps I exaggerate. I’ve not had any fun with Exception Notifier today. In fact, I’ve had a lot of NOT fun! So I’m here to help you have less anti-fun than I had.

Exception Notifier (here’s a tutorial) is a great way to get Rails to email you when a critical error occurs in your app. It automatically ignores 404-like errors which is probably good most of the time.

I started by installing the plugin earlier today which is totally straight-forward…

script/install plugin exception_notification

Pretty easy, right? Right.

The README tells you all you need to know about how to configure it…or so you would think.

Personally I like to try my shiz out on my development box before I just throw someone else’s code (granted, Jamis is no slouch) up on my production site. So, I commence with the configuring and forcing my app to error out. I even try hitting my site from a totally different computer so it’ll ignore my “local” request. I get lots of errors, lots of trace info, but no email. Nothing even looking like an attempt.

Digging through the code I find some stuff about ignoring local requests so I figure I should hack that to allow my request to appear non-local. If you’re not a Rails noob (I am) you’ll have already figured out my problem by what I just said. You see, when you’re in development mode, EVERY REQUEST IS LOCAL by default. It doesn’t matter if you are hitting the site from around the globe, if you’re in development mode, it’s a local request. Normally that’s great but when you’re trying to test your freakin exception mailer, IT SUCKS!

Fortunately all problems were solved simply by editing development.rb. Change the line that says config.action_controller.consider_all_requests_local = true to false and BOOM, exception mailing! This is assuming, of course, that you have the ActionMailer stuff configured properly (which was another part of my problem). By the way, there’s also a line in development.rb that looks like config.action_mailer.raise_delivery_errors = false

I like to set that to true so I can see the whole conversation between the app and the mail server.

By the way, I’m using Google Apps for my email server (which I love) but it takes some massaging to get Rails to mail to it. There are a number of articles out on how to do it.

Oh, and if you happened to read the tutorial I posted at the beginning of the article, including the comments, you would notice that what I just told you was in there. Guess who didn’t read it all the way through? Ya. G’night.

Sorry, comments are closed for this article.