diff options
author | Claire McQuin <claire@getchef.com> | 2014-05-13 14:13:33 -0700 |
---|---|---|
committer | Claire McQuin <claire@getchef.com> | 2014-05-13 15:21:16 -0700 |
commit | 0ec0e7f2599a6aa16633c0ee79cadb5c1cb65e1c (patch) | |
tree | a8a86b6c5dbb693ab887c2fd2365db01ace802c7 | |
parent | d09ee38fa4ac3e77e75485b95a282890af35e61a (diff) | |
download | chef-0ec0e7f2599a6aa16633c0ee79cadb5c1cb65e1c.tar.gz |
Catch format error for 504 Gateway Time-out.
-rw-r--r-- | lib/chef/formatters/error_inspectors/api_error_formatting.rb | 15 | ||||
-rw-r--r-- | lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb | 4 |
2 files changed, 15 insertions, 4 deletions
diff --git a/lib/chef/formatters/error_inspectors/api_error_formatting.rb b/lib/chef/formatters/error_inspectors/api_error_formatting.rb index 1e4e258906..dca2835f23 100644 --- a/lib/chef/formatters/error_inspectors/api_error_formatting.rb +++ b/lib/chef/formatters/error_inspectors/api_error_formatting.rb @@ -88,7 +88,20 @@ E def format_rest_error Array(Chef::JSONCompat.from_json(exception.response.body)["error"]).join('; ') rescue Exception - exception.response.body + # When we get 504 from the server, sometimes the response body is non-readable. + # + # Stack trace: + # + # NoMethodError: undefined method `closed?' for nil:NilClass + # .../lib/ruby/1.9.1/net/http.rb:2789:in `stream_check' + # .../lib/ruby/1.9.1/net/http.rb:2709:in `read_body' + # .../lib/ruby/1.9.1/net/http.rb:2736:in `body' + # .../lib/chef/formatters/error_inspectors/api_error_formatting.rb:91:in `rescue in format_rest_error' + begin + exception.response.body + rescue Exception + "Cannot fetch the contents of the response." + end end def username diff --git a/lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb b/lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb index 56a55a296b..0cb849a17f 100644 --- a/lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb +++ b/lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb @@ -65,7 +65,7 @@ class Chef when Net::HTTPNotFound when Net::HTTPInternalServerError describe_500_error(error_description) - when Net::HTTPBadGateway, Net::HTTPServiceUnavailable + when Net::HTTPBadGateway, Net::HTTPServiceUnavailable, Net::HTTPGatewayTimeOut describe_503_error(error_description) else describe_http_error(error_description) @@ -76,5 +76,3 @@ class Chef end end end - - |