class ChefCLI::ServiceExceptionInspectors::HTTP
Attributes
exception[R]
Public Class Methods
new(exception)
click to toggle source
# File lib/chef-cli/service_exception_inspectors/http.rb, line 26 def initialize(exception) @exception = exception end
Public Instance Methods
attempt_error_message_extract()
click to toggle source
# File lib/chef-cli/service_exception_inspectors/http.rb, line 68 def attempt_error_message_extract error_body = FFI_Yajl::Parser.parse(response_body) if error_body.respond_to?(:key?) && error_body.key?("error") Array(error_body["error"]).join(", ") else error_body.to_s end rescue response_body end
code()
click to toggle source
# File lib/chef-cli/service_exception_inspectors/http.rb, line 48 def code response.code end
extended_error_info()
click to toggle source
# File lib/chef-cli/service_exception_inspectors/http.rb, line 34 def extended_error_info <<~END --- RESPONSE DATA --- #{code} #{response_message} #{response_headers} #{response_body} END end
message()
click to toggle source
# File lib/chef-cli/service_exception_inspectors/http.rb, line 30 def message "HTTP #{code} #{response_message}: " + parsed_response_body end
parsed_response_body()
click to toggle source
# File lib/chef-cli/service_exception_inspectors/http.rb, line 60 def parsed_response_body if response_body && !response_body.empty? attempt_error_message_extract else "(No explanation provided by server)" end end
response()
click to toggle source
# File lib/chef-cli/service_exception_inspectors/http.rb, line 44 def response exception.response end
response_body()
click to toggle source
# File lib/chef-cli/service_exception_inspectors/http.rb, line 56 def response_body response.body end
response_headers()
click to toggle source
# File lib/chef-cli/service_exception_inspectors/http.rb, line 79 def response_headers headers_s = "" response.each_header do |key, value| headers_s << key << ": " << value << "\n" end headers_s end
response_message()
click to toggle source
# File lib/chef-cli/service_exception_inspectors/http.rb, line 52 def response_message response.message end
uri()
click to toggle source
# File lib/chef-cli/service_exception_inspectors/http.rb, line 87 def uri request.uri.to_s + request.path.to_s end