I'm using the Rails exception_notification plugin in my app and find it very useful.

However, there are occasions when I want to catch an exception and deal with it gracefully but still would like to receive the exception notification email. It only seems to send for uncaught exceptions it seems.

Does anyone know how to force send the email for when you've already caught the exception?


Exception Notifier is specifically designed for catching uncaught errors. Once you catch the error its up to you to send the email message yourself. The quick and dirty way is to trigger the exception mailer code when you catch the exception. I can't recall how the method off the top of my head, but a quick look in the plugin should yield you results. Look for the render_exception_in_public (or something like it) for the mailer code.

Peer Allan
+4  A: 

I figured out how to do this. Here's the code that you would put in your controller to trigger the email.

    10 / 0
rescue Exception => e
    ExceptionNotifier.deliver_exception_notification(e, self, request)