diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-05-18 11:54:51 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-05-18 11:54:51 -0700 |
commit | cf6e025a4538e488ed35f61f1f7f3498833a34e6 (patch) | |
tree | 6a28d5beac35e74a33243668baf7a9a60edf6724 /actionpack/lib/action_dispatch/middleware/failsafe.rb | |
parent | 628110d7eeb446fee7f9e043f113c083d24883c1 (diff) | |
parent | 195fadbfd31294d43634afb7bbf4f0ffc86b470a (diff) | |
download | rails-cf6e025a4538e488ed35f61f1f7f3498833a34e6.tar.gz rails-cf6e025a4538e488ed35f61f1f7f3498833a34e6.tar.bz2 rails-cf6e025a4538e488ed35f61f1f7f3498833a34e6.zip |
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'actionpack/lib/action_dispatch/middleware/failsafe.rb')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/failsafe.rb | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/failsafe.rb b/actionpack/lib/action_dispatch/middleware/failsafe.rb deleted file mode 100644 index 836098482c..0000000000 --- a/actionpack/lib/action_dispatch/middleware/failsafe.rb +++ /dev/null @@ -1,52 +0,0 @@ -module ActionDispatch - class Failsafe - cattr_accessor :error_file_path - self.error_file_path = Rails.public_path if defined?(Rails.public_path) - - def initialize(app) - @app = app - end - - def call(env) - @app.call(env) - rescue Exception => exception - # Reraise exception in test environment - if defined?(Rails) && Rails.env.test? - raise exception - else - failsafe_response(exception) - end - end - - private - def failsafe_response(exception) - log_failsafe_exception(exception) - [500, {'Content-Type' => 'text/html'}, failsafe_response_body] - rescue Exception => failsafe_error # Logger or IO errors - $stderr.puts "Error during failsafe response: #{failsafe_error}" - end - - def failsafe_response_body - error_path = "#{self.class.error_file_path}/500.html" - if File.exist?(error_path) - [File.read(error_path)] - else - ["<html><body><h1>500 Internal Server Error</h1></body></html>"] - end - end - - def log_failsafe_exception(exception) - message = "/!\\ FAILSAFE /!\\ #{Time.now}\n Status: 500 Internal Server Error\n" - message << " #{exception}\n #{exception.backtrace.join("\n ")}" if exception - failsafe_logger.fatal(message) - end - - def failsafe_logger - if defined?(Rails) && Rails.logger - Rails.logger - else - Logger.new($stderr) - end - end - end -end |