static public Method

Dispatcher.failsafe_response(fallback_output, status, originating_exception = nil) { || ... }

If the block raises, send status code as a last-ditch response.

Source Code

# File action_controller/dispatcher.rb, line 37
def failsafe_response(fallback_output, status, originating_exception = nil)
  yield
rescue Exception => exception
  begin
    log_failsafe_exception(status, originating_exception || exception)
    body = failsafe_response_body(status)
    fallback_output.write "Status: #{status}\r\nContent-Type: text/html\r\n\r\n#{body}"
    nil
  rescue Exception => failsafe_error # Logger or IO errors
    $stderr.puts "Error during failsafe response: #{failsafe_error}"
    $stderr.puts "(originally #{originating_exception})" if originating_exception
  end
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.