diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-04-05 04:52:31 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-04-05 04:52:31 +0000 |
commit | 11323ceb2833512e727fba6d7a7f61befeee4bfd (patch) | |
tree | 81c629fa2cb50f9a5a006d16230748dffb0049dd | |
parent | 4859b6c09e188462b4d29328c0bb891cd98d8f31 (diff) | |
download | rails-11323ceb2833512e727fba6d7a7f61befeee4bfd.tar.gz rails-11323ceb2833512e727fba6d7a7f61befeee4bfd.tar.bz2 rails-11323ceb2833512e727fba6d7a7f61befeee4bfd.zip |
Added that Dispatcher exceptions should not be shown to the user unless a default log has not been configured. Instead show public/500.html [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4168 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | railties/CHANGELOG | 2 | ||||
-rw-r--r-- | railties/lib/dispatcher.rb | 22 |
2 files changed, 22 insertions, 2 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG index cc567cecf9..8eccbfcd93 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added that Dispatcher exceptions should not be shown to the user unless a default log has not been configured. Instead show public/500.html [DHH] + * Fixed that rake clone_structure_to_test should quit on pgsql if the dump is unsuccesful #4585 [augustz@augustz.com] * Fixed that rails --version should have the return code of 0 (success) #4560 [blair@orcaware.com] diff --git a/railties/lib/dispatcher.rb b/railties/lib/dispatcher.rb index be194cd2b0..721a367f71 100644 --- a/railties/lib/dispatcher.rb +++ b/railties/lib/dispatcher.rb @@ -90,8 +90,26 @@ class Dispatcher rescue Object begin output.write "Status: #{status}\r\n" - output.write "Content-Type: text/plain\r\n\r\n" - output.write(exception.to_s + "\r\n" + exception.backtrace.join("\r\n")) if exception + + if exception + message = exception.to_s + "\r\n" + exception.backtrace.join("\r\n") + error_path = File.join(RAILS_ROOT, 'public', '500.html') + + if defined?(RAILS_DEFAULT_LOGGER) && !RAILS_DEFAULT_LOGGER.nil? + RAILS_DEFAULT_LOGGER.fatal(message) + + output.write "Content-Type: text/html\r\n\r\n" + + if File.exists?(error_path) + output.write(IO.read(error_path)) + else + output.write("<html><body><h1>Application error (Rails)</h1></body></html>") + end + else + output.write "Content-Type: text/plain\r\n\r\n" + output.write(message) + end + end rescue Object end end |