rtacconi
rtacconi

Reputation: 14779

Catch all exceptions in a Rails 3 application

I would like to catch all exceptions in a Rails 3 application. I tried to put a begin rescue around Cms::Application.initialize! (in config/environment) but it does not work:

begin
  Cms::Application.initialize!
rescue
  # notify me
end

I few words I would like to try to have a basic exception notification. I know there are plug ins and services around, but I want to do it on my own

Upvotes: 1

Views: 2264

Answers (1)

Nick
Nick

Reputation: 2478

You can catch them in your application controller.

class ApplicationController < ActionController::Base
  rescue_from(Exception) { # Or just handle particular exceptions
  # do stuff
  }
end

Upvotes: 4

Related Questions