1

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

1 Answer 1

4

You can catch them in your application controller.

class ApplicationController < ActionController::Base
  rescue_from(Exception) { # Or just handle particular exceptions
  # do stuff
  }
end
Sign up to request clarification or add additional context in comments.

2 Comments

And you've put that in application_controller.rb?
rescuing StandardError is usually better than Exception: awesomerails.wordpress.com/2008/10/07/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.