Created
September 11, 2010 23:37
-
-
Save thbishop/575683 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin | |
res = @http.request(req) | |
unless res.kind_of?(Net::HTTPSuccess) | |
res.error! | |
end | |
rescue Timeout::Error, Errno::EINVAL, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ETIMEDOUT, NoMethodError => e | |
# http://redmine.ruby-lang.org/issues/show/2708 | |
# http://redmine.ruby-lang.org/issues/show/2758 | |
if e.to_s =~ /#{Regexp.escape(%q|undefined method 'closed?' for nil:NilClass|)}/ | |
Chef::Log.fatal("POST to Solr encountered exception Errno::ECONNREFUSED: net/http undefined method closed?") | |
Chef::Log.debug("rescued error in http connect, treating it as Errno::ECONNREFUSED to hide bug in net/http") | |
raise Errno::ECONNREFUSED | |
else | |
Chef::Log.fatal("POST to Solr encountered exception #{e.class}: #{e.to_s}") | |
end | |
raise e | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment