Class/Module Index [+]

Quicksearch

Chef::Formatters::APIErrorFormatting

Public Instance Methods

api_key() click to toggle source
# File lib/chef/formatters/error_inspectors/api_error_formatting.rb, line 97
def api_key
  config[:client_key]
end
clock_skew?() click to toggle source
# File lib/chef/formatters/error_inspectors/api_error_formatting.rb, line 105
def clock_skew?
  exception.response.body =~ /synchronize the clock/
end
describe_400_error(error_description) click to toggle source
# File lib/chef/formatters/error_inspectors/api_error_formatting.rb, line 60
def describe_400_error(error_description)
  error_description.section("Invalid Request Data:",The data in your request was invalid (HTTP 400).)
  error_description.section("Server Response:",format_rest_error)
end
describe_401_error(error_description) click to toggle source
# File lib/chef/formatters/error_inspectors/api_error_formatting.rb, line 37
def describe_401_error(error_description)
  if clock_skew?
    error_description.section("Authentication Error:",Failed to authenticate to the chef server (http 401).The request failed because your clock has drifted by more than 15 minutes.Syncing your clock to an NTP Time source should resolve the issue.)
  else
    error_description.section("Authentication Error:",Failed to authenticate to the chef server (http 401).)

    error_description.section("Server Response:", format_rest_error)
    error_description.section("Relevant Config Settings:",chef_server_url   "#{server_url}"node_name         "#{username}"client_key        "#{api_key}"If these settings are correct, your client_key may be invalid.)
  end
end
describe_500_error(error_description) click to toggle source
# File lib/chef/formatters/error_inspectors/api_error_formatting.rb, line 67
def describe_500_error(error_description)
  error_description.section("Unknown Server Error:",The server had a fatal error attempting to load the node data.)
  error_description.section("Server Response:", format_rest_error)
end
describe_503_error(error_description) click to toggle source
# File lib/chef/formatters/error_inspectors/api_error_formatting.rb, line 74
def describe_503_error(error_description)
  error_description.section("Server Unavailable","The Chef Server is temporarily unavailable")
  error_description.section("Server Response:", format_rest_error)
end
describe_http_error(error_description) click to toggle source

Fallback for unexpected/uncommon http errors

# File lib/chef/formatters/error_inspectors/api_error_formatting.rb, line 81
def describe_http_error(error_description)
  error_description.section("Unexpected API Request Failure:", format_rest_error)
end
describe_network_errors(error_description) click to toggle source
# File lib/chef/formatters/error_inspectors/api_error_formatting.rb, line 26
def describe_network_errors(error_description)
  error_description.section("Networking Error:",#{exception.message}Your chef_server_url may be misconfigured, or the network could be down.)
  error_description.section("Relevant Config Settings:",chef_server_url  "#{server_url}")
end
format_rest_error() click to toggle source

Parses JSON from the error response sent by Chef Server and returns the error message

# File lib/chef/formatters/error_inspectors/api_error_formatting.rb, line 87
def format_rest_error
  Array(Chef::JSONCompat.from_json(exception.response.body)["error"]).join('; ')
rescue Exception
  exception.response.body
end
server_url() click to toggle source
# File lib/chef/formatters/error_inspectors/api_error_formatting.rb, line 101
def server_url
  config[:chef_server_url]
end
username() click to toggle source
# File lib/chef/formatters/error_inspectors/api_error_formatting.rb, line 93
def username
  config[:node_name]
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.