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.


5
6
7
8
9
10
11
12
13
14
15
16
17
# 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
  elsif(http_obj.instance_of?(HTTParty::Response))
    @message = message.concat("|| Explanation: ").concat(http_obj.parsed_response["errorDetails"].to_s) unless http_obj.parsed_response["errorDetails"].nil?
    @type = http_obj.parsed_response["errorType"]
    @response = http_obj.response
    @request = http_obj.request
    @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.


19
20
21
# File 'lib/nexosis_api/http_exception.rb', line 19

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.


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

def type
  @type
end