aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/dispatch/rack/failsafe.rb
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-01-27 18:54:01 -0600
committerJoshua Peek <josh@joshpeek.com>2009-01-27 18:54:01 -0600
commit319ae4628f4e0058de3e40e4ca7791b17e45e70c (patch)
treee5da1bfe6dd69a9cf483c9ff9fd18c5bfdd2f463 /actionpack/lib/action_controller/dispatch/rack/failsafe.rb
parenta0f2b1d95d3785de92ae271fd7ea23e91c0cadc6 (diff)
downloadrails-319ae4628f4e0058de3e40e4ca7791b17e45e70c.tar.gz
rails-319ae4628f4e0058de3e40e4ca7791b17e45e70c.tar.bz2
rails-319ae4628f4e0058de3e40e4ca7791b17e45e70c.zip
Move HTTP libs and middleware into ActionDispatch component
Diffstat (limited to 'actionpack/lib/action_controller/dispatch/rack/failsafe.rb')
-rw-r--r--actionpack/lib/action_controller/dispatch/rack/failsafe.rb52
1 files changed, 0 insertions, 52 deletions
diff --git a/actionpack/lib/action_controller/dispatch/rack/failsafe.rb b/actionpack/lib/action_controller/dispatch/rack/failsafe.rb
deleted file mode 100644
index 567581142c..0000000000
--- a/actionpack/lib/action_controller/dispatch/rack/failsafe.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-module ActionController
- 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 env["rack.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