class Honeybadger::Backend::Response

def error_message

def error_message
  return message if code == :error
  return FRIENDLY_ERRORS[code] if FRIENDLY_ERRORS[code]
  return error if error =~ NOT_BLANK
  msg = "The server responded with #{code}"
  msg << ": #{message}" if message =~ NOT_BLANK
  msg
end

def initialize(*args)

Parameters:
  • message (String) -- The String message returned by the server (or
  • body (String) -- The String body of the response.
  • code (Integer) -- The status code. May also be :error for requests
  • response (Net::HTTPResponse) -- With 1 argument, the code, body,

Overloads:
  • initialize(code, body, message)
  • initialize(response)
def initialize(*args)
  if (response = args.first).kind_of?(Net::HTTPResponse)
    @code, @body, @message = response.code.to_i, response.body.to_s, response.message
  else
    @code, @body, @message = args
  end
  @success = (200..299).cover?(@code)
  @error = parse_error(body) unless @success
end

def parse_error(body)

def parse_error(body)
  return unless body =~ NOT_BLANK
  obj = JSON.parse(body)
  return obj['error'] if obj.kind_of?(Hash)
rescue JSON::ParserError
  nil
end

def success?

def success?
  @success
end