aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/rescue.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-02-15 01:45:35 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-02-15 01:45:35 +0000
commitb1999be5a7efd67e2602c37ed898aa8433661863 (patch)
tree03bc833276075d802d0ce0ad261baed3d7232533 /actionpack/lib/action_controller/rescue.rb
parent88a3343ed57c01ca358da8473d15fc4d2b4a5bff (diff)
downloadrails-b1999be5a7efd67e2602c37ed898aa8433661863.tar.gz
rails-b1999be5a7efd67e2602c37ed898aa8433661863.tar.bz2
rails-b1999be5a7efd67e2602c37ed898aa8433661863.zip
A hopefully more successful attempt at the Routing branch merge
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@617 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/rescue.rb')
-rw-r--r--actionpack/lib/action_controller/rescue.rb18
1 files changed, 15 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/rescue.rb b/actionpack/lib/action_controller/rescue.rb
index eb7f614de0..907cebc250 100644
--- a/actionpack/lib/action_controller/rescue.rb
+++ b/actionpack/lib/action_controller/rescue.rb
@@ -48,7 +48,11 @@ module ActionController #:nodoc:
# Overwrite to implement public exception handling (for requests answering false to <tt>local_request?</tt>).
def rescue_action_in_public(exception) #:doc:
- render_text "<html><body><h1>Application error (Rails)</h1></body></html>"
+ case exception
+ when RoutingError, UnknownAction then
+ render_text(IO.read(File.join(RAILS_ROOT, 'public', '404.html')), "404 Not Found")
+ else render_text "<html><body><h1>Application error (Rails)</h1></body></html>"
+ end
end
# Overwrite to expand the meaning of a local request in order to show local rescues on other occurences than
@@ -66,7 +70,7 @@ module ActionController #:nodoc:
@contents = @template.render_file(template_path_for_local_rescue(exception), false)
@headers["Content-Type"] = "text/html"
- render_file(rescues_path("layout"), "500 Internal Error")
+ render_file(rescues_path("layout"), response_code_for_rescue(exception))
end
private
@@ -110,13 +114,21 @@ module ActionController #:nodoc:
rescues_path(
case exception
when MissingTemplate then "missing_template"
+ when RoutingError then "routing_error"
when UnknownAction then "unknown_action"
when ActionView::TemplateError then "template_error"
- else "diagnostics"
+ else raise ;"diagnostics"
end
)
end
+ def response_code_for_rescue(exception)
+ case exception
+ when UnknownAction, RoutingError then "404 Page Not Found"
+ else "500 Internal Error"
+ end
+ end
+
def clean_backtrace(exception)
exception.backtrace.collect { |line| Object.const_defined?(:RAILS_ROOT) ? line.gsub(RAILS_ROOT, "") : line }
end