Exception: NexosisApi::HttpException

Inherits:
StandardError
  • Object
show all
Defined in:
lib/nexosis_api/http_exception.rb

Overview

encapsulate errors from the Nexosis API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of HttpException.

[View source]

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

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.


4
5
6
# File 'lib/nexosis_api/http_exception.rb', line 4

def action
  @action
end

#codeObject (readonly)

Returns the value of attribute code.


22
23
24
# File 'lib/nexosis_api/http_exception.rb', line 22

def code
  @code
end

#messageObject (readonly)

Returns the value of attribute message.


4
5
6
# File 'lib/nexosis_api/http_exception.rb', line 4

def message
  @message
end

#requestObject (readonly)

Returns the value of attribute request.


4
5
6
# File 'lib/nexosis_api/http_exception.rb', line 4

def request
  @request
end

#responseObject (readonly)

Returns the value of attribute response.


4
5
6
# File 'lib/nexosis_api/http_exception.rb', line 4

def response
  @response
end

#typeObject (readonly)

Returns the value of attribute type.


26
27
28
# File 'lib/nexosis_api/http_exception.rb', line 26

def type
  @type
end