aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/application_controller.rb
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-05-01 16:37:04 +0100
committerLouise Crow <louise.crow@gmail.com>2013-05-02 10:20:53 +0100
commit0b6b29f248a74321638f5149800dac777080a95b (patch)
tree1e61f5cc0e786278cfc6bdaf888bf64734b09de0 /app/controllers/application_controller.rb
parent2b1ec0102078aef523736eb1b24311e458a403a0 (diff)
Add new error handler method that renders the general/exception_caught template
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r--app/controllers/application_controller.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 029b536ec..d062519bc 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -12,6 +12,11 @@ require 'open-uri'
class ApplicationController < ActionController::Base
class PermissionDenied < StandardError
end
+ # assign our own handler method for non-local exceptions
+ if ! Rails.application.config.consider_all_requests_local
+ rescue_from Exception, :with => :render_exception
+ end
+
# Standard headers, footers and navigation for whole site
layout "default"
include FastGettext::Translation # make functions like _, n_, N_ etc available)
@@ -111,6 +116,14 @@ class ApplicationController < ActionController::Base
end
end
+ def render_exception(exception)
+ @exception_backtrace = exception.backtrace.join("\n")
+ @exception_class = exception.class.to_s
+ @exception_message = exception.message
+ status_code = case exception
+ render :template => "general/exception_caught", :status => status_code
+ end
+
# Override default error handler, for production sites.
def rescue_action_in_public(exception)
# Looks for before_filters called something like `set_view_paths_{themename}`. These