app/controllers/umlaut/error_handling.rb in umlaut-3.1.0.pre2 vs app/controllers/umlaut/error_handling.rb in umlaut-3.1.0
- old
+ new
@@ -1,6 +1,5 @@
-# A mix-in for Rails controllers with some standard error recovery
# logic.
module Umlaut::ErrorHandling
extend ActiveSupport::Concern
included do
@@ -11,15 +10,22 @@
rescue_from ActiveRecord::RecordNotFound, :with => :handle_404_error
end
end
def handle_general_error(exception)
+
log_error_with_context(exception)
@page_title = "Error!"
# Only render this if we haven't done anything else
- # e.g. if some other gem may be handling its own errors
- render "error", :status => 500 unless performed?
+ # e.g. if some other gem may be handling its own errors
+ unless performed?
+ if params[:format] == "html"
+ render "error", :status => 500
+ else
+ render :text => "Unexpected fatal error, has been logged.", :status => 500
+ end
+ end
end
protected :handle_general_error
# Just returns a generic 404 page.
# Uses generic 404 page already stored in public/404.html as rails convention.
@@ -40,6 +46,6 @@
# we actually get a backtrace.
message << " " << Rails.backtrace_cleaner.clean(exception.backtrace, :noise).join("\n ")
logger.send(severity, "#{message}\n\n")
end
protected :log_error_with_context
-end
\ No newline at end of file
+end