I’ve been using Exceptional for all of my Rails apps lately and I’ve been very happy with it. For one of my current apps, I’ve got a couple of scripts that run automatically (daily and weekly cron jobs). I had created a Lighthouse ticket a while back to make sure that exceptions that occurred in these scripts would be caught by Exceptional.
It turns out that they weren’t, but things could be fixed up in a couple of steps. First, install the exceptional gem:
gem install constrast-exceptional
You can then wrap your existing code with an Exceptional rescue wrapper. I had some trouble with this part and contacted Paul Campbell from Exceptional with an error I was having. Turns out it was in the order that I was loading things - the following is the skeleton of my scripts. Hopefully this saves someone a headache someday.
#!/usr/bin/env ruby
require 'rubygems'
require 'lockfile'
Lockfile('lock', :retries => 0) do
require File.dirname(__FILE__) + '/../config/boot'
require File.dirname(__FILE__) + '/../config/environment'
require 'exceptional'
Exceptional.api_key = "YOURKEYHERE"
Exceptional.rescue do
# Your code here
end
end