567581142c218a8e4322da8dc25d88ee731e183c
1 module ActionController
3 cattr_accessor
:error_file_path
4 self.error_file_path
= Rails
.public_path
if defined?(Rails
.public_path
)
12 rescue Exception
=> exception
13 # Reraise exception in test environment
17 failsafe_response(exception
)
22 def failsafe_response(exception
)
23 log_failsafe_exception(exception
)
24 [500, {'Content-Type' => 'text/html'}, failsafe_response_body
]
25 rescue Exception
=> failsafe_error
# Logger or IO errors
26 $stderr.puts
"Error during failsafe response: #{failsafe_error}"
29 def failsafe_response_body
30 error_path
= "#{self.class.error_file_path}/500.html"
31 if File
.exist
?(error_path
)
34 "<html><body><h1>500 Internal Server Error</h1></body></html>"
38 def log_failsafe_exception(exception
)
39 message
= "/!\\ FAILSAFE /!\\ #{Time.now}\n Status: 500 Internal Server Error\n"
40 message
<< " #{exception}\n #{exception.backtrace.join("\n ")}" if exception
41 failsafe_logger
.fatal(message
)
45 if defined?(Rails
) && Rails
.logger