Method: NexosisApi::HttpException#initialize

Defined in:
lib/nexosis_api/http_exception.rb

#initialize(message = "", action = nil, http_obj) ⇒ HttpException

Returns a new instance of HttpException.


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/nexosis_api/http_exception.rb', line 5

def initialize(message = "", action = nil, http_obj)
  @message = message
  if(http_obj.is_a?(Hash))
  @message.prepend(http_obj["message"].concat(": ")) unless http_obj["message"].nil?
  @action = action
    if(http_obj.instance_of?(HTTParty::Response))
      @message = message.concat("|| Explanation: ").concat(http_obj["errorDetails"]["message"]) unless http_obj["errorDetails"]["message"].nil?
      @code = http_obj.parsed_response["statusCode"]
      @type = http_obj.parsed_response["errorType"]
      @response = http_obj.response
      @request = http_obj.request
    end
  else
    @code = http_obj.code
  end
end