Question

I'm trying to use exception_notification for the first time. I watched the Railscast and followed instructions from the author in http://smartinez87.github.io/exception_notification/. Everything seems to work fine with some sort of exceptions but not with others.

I tested and received email error notificatios from my dev environment with errors such as "An ActionView::Template::Error occurred in static_pages#home:". But, there are some Exceptions such as RoutingException and RecordNotFound that are not being catched by ExceptionNotification, and I don't know why, as I have not any rescue_from strategy of any kind in my application_controller.

I'm using rails 3.2.12 and checked the middleware stack array, and I can see ExceptionNotification is just the last one, and it seems that some kind of exceptions does not go their way down the stack, so Exception Notification is not aware of them.

So, the question are: what am i doing wrong? what is the difference between ActionController::RoutingError or ActiveRecord::RecordNotFound which are not catched by ExceptionNotification and ActionView::Template::Error which is catched and causes Exception Notification to send the notification email to my inbox.

Thanks in advance

Was it helpful?

Solution

These exception types are being ignored as part of the default configuration of that gem. See line 25 here: https://github.com/smartinez87/exception_notification/blob/master/lib/exception_notifier.rb which currently reads:

@@ignored_exceptions = %w{ActiveRecord::RecordNotFound AbstractController::ActionNotFound ActionController::RoutingError ActionController::UnknownFormat}

You can override this behavior in your environment file (i.e. development.rb, etc).

Example to notify on ALL errors:

config.middleware.use ExceptionNotifier,
  ignore_exceptions: []

Example to add RuntimeError to the default ignore list:

config.middleware.use ExceptionNotifier,
  ignore_exceptions: ExceptionNotifier.default_ignore_exceptions + [RuntimeError]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top