diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-06 18:25:01 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-06 18:25:01 +0000 |
commit | 0ffb6c16258b5c39a7417f4563edf0fc7542c9ae (patch) | |
tree | 2242cb28635f99410268f48d0415e97b4c5a5de1 /actionpack/lib/action_controller/rescue.rb | |
parent | ed14042feac6ff84670958fc3e2017aaacac5856 (diff) | |
download | rails-0ffb6c16258b5c39a7417f4563edf0fc7542c9ae.tar.gz rails-0ffb6c16258b5c39a7417f4563edf0fc7542c9ae.tar.bz2 rails-0ffb6c16258b5c39a7417f4563edf0fc7542c9ae.zip |
Syntax errors and other exceptions thrown outside of an action are now gracefully handled by the dispatcher
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@51 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/rescue.rb')
-rw-r--r-- | actionpack/lib/action_controller/rescue.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/rescue.rb b/actionpack/lib/action_controller/rescue.rb index e624888b64..328eca7fe4 100644 --- a/actionpack/lib/action_controller/rescue.rb +++ b/actionpack/lib/action_controller/rescue.rb @@ -8,12 +8,19 @@ module ActionController #:nodoc: module Rescue def self.append_features(base) #:nodoc: super + base.extend(ClassMethods) base.class_eval do alias_method :perform_action_without_rescue, :perform_action alias_method :perform_action, :perform_action_with_rescue end end + module ClassMethods + def process_with_exception(request, response, exception) + new.process(request, response, :rescue_action, exception) + end + end + protected # Exception handler called when the performance of an action raises an exception. def rescue_action(exception) @@ -87,8 +94,7 @@ module ActionController #:nodoc: end def clean_backtrace(exception) - base_dir = File.expand_path(File.dirname(__FILE__) + "/../../../../") - exception.backtrace.collect { |line| line.gsub(base_dir, "").gsub("/public/../config/environments/../../", "").gsub("/public/../", "") } + exception.backtrace.collect { |line| Object.const_defined?(:RAILS_ROOT) ? line.gsub(RAILS_ROOT, "") : line } end end end |