Created
May 14, 2012 14:40
-
-
Save modsaid/2694370 to your computer and use it in GitHub Desktop.
Default rescue for all actions/controllers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#To be placed in application_controller.rb | |
rescue_from Exception, :with => :rescue_all_exceptions unless %W(development test).include?(Rails.env) | |
def rescue_all_exceptions(exception) | |
buffer = "[EXCEPTION] " | |
buffer << exception.message << "\t(Request: #{request.url}\t Referrer: (#{request.env['HTTP_REFERER']} ) \n\t" | |
buffer << exception.backtrace.join("\n\t") | |
Rails.logger.error buffer | |
respond_to do |format| | |
format.html { redirect_to '/500.html'} | |
format.js { render :nothing => true, :status => 500 } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment