Thursday, June 28, 2007

Ignoring common exceptions in exception_notification plugin

Exception Notification is a great plugin, that helps to you to get trace of exception on your app running in production mode. Without this plugin you probably would have to SSH to production machine and tail the production.log file to get last exception trace which is extremely inconvenient to do. FTP to get to production.log is also an option but production.log files tend to become too large. only problem is that you may get too many emails form this plugin especially when you have just launched your site in production mode.

some of the exception are not too much intresting like typical ActiveRecord::RecordNotFound exceptions, To ignore these kind of trivial exceptions you must overide it in rescue_action_in_public method of your application.rb file.

Here is how you do it:

def rescue_action_in_public(exception)
case exception
when ::ActiveRecord::RecordNotFound,
deliverer = self.class.exception_data
data = case deliverer
when nil then {}
when Symbol then send(deliverer)
when Proc then
ExceptionNotifier.deliver_exception_notification(exception, self, request, data)

No comments: