Method: Chef::Formatters::APIErrorFormatting#safe_format_rest_error

Defined in:
lib/chef/formatters/error_inspectors/api_error_formatting.rb

#safe_format_rest_errorObject



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/chef/formatters/error_inspectors/api_error_formatting.rb', line 167

def safe_format_rest_error
  # 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'

  exception.response.body
rescue Exception
  "Cannot fetch the contents of the response."
end