Method: Chef::Formatters::ErrorInspectors::NodeLoadErrorInspector#humanize_http_exception

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

#humanize_http_exception(error_description) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/chef/formatters/error_inspectors/node_load_error_inspector.rb', line 63

def humanize_http_exception(error_description)
  response = exception.response
  case response
  when Net::HTTPUnauthorized
    # TODO: this is where you'd see conflicts b/c of username/clientname stuff
    describe_401_error(error_description)
  when Net::HTTPForbidden
    # TODO: we're rescuing errors from Node.find_or_create
    # * could be no write on nodes container
    # * could be no read on the node
    error_description.section("Authorization Error", "      Your client is not authorized to load the node data (HTTP 403).\n    E\n    error_description.section(\"Server Response:\", format_rest_error)\n\n    error_description.section(\"Possible Causes:\", <<~E)\n      * Your client (\#{username}) may have misconfigured authorization permissions.\n    E\n  when Net::HTTPBadRequest\n    describe_400_error(error_description)\n  when Net::HTTPNotFound\n    describe_404_error(error_description)\n  when Net::HTTPInternalServerError\n    describe_500_error(error_description)\n  when Net::HTTPBadGateway, Net::HTTPServiceUnavailable\n    describe_503_error(error_description)\n  when Net::HTTPNotAcceptable\n    describe_406_error(error_description, response)\n  else\n    describe_http_error(error_description)\n  end\nend\n")