Skip to content

Instantly share code, notes, and snippets.

@modsaid
Created May 14, 2012 14:40
Show Gist options
  • Save modsaid/2694370 to your computer and use it in GitHub Desktop.
Save modsaid/2694370 to your computer and use it in GitHub Desktop.
Default rescue for all actions/controllers
#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