Exception: BayonetClient::BayonetError

Inherits:
Exception
  • Object
show all
Defined in:
lib/bayonet_client/exceptions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_body, request_headers, http_response_code, http_response_json, reason_code = nil, reason_message = nil) ⇒ BayonetError

Returns a new instance of BayonetError.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/bayonet_client/exceptions.rb', line 9

def initialize(request_body, request_headers,
               http_response_code, http_response_json, reason_code = nil, reason_message = nil)
  self.request_body = request_body
  self.request_headers = request_headers
  self.http_response_code = http_response_code
  self.http_response_json = http_response_json
  self.reason_code = reason_code
  self.reason_message = reason_message

  # Get reason_code and reason_message from response
  if http_response_json.class == HTTParty::Response && http_response_json.key?('reason_code')
    self.reason_code = http_response_json['reason_code']
  end
  if http_response_json.class == HTTParty::Response && http_response_json.key?('reason_message')
    self.reason_message = http_response_json['reason_message']
  end
  if http_response_json.class == HTTParty::Response && http_response_json.key?('status')
    self.reason_message = http_response_json['status']
    self.reason_code = -1
  end
end

Instance Attribute Details

#http_response_codeObject

Returns the value of attribute http_response_code.



6
7
8
# File 'lib/bayonet_client/exceptions.rb', line 6

def http_response_code
  @http_response_code
end

#http_response_jsonObject

Returns the value of attribute http_response_json.



6
7
8
# File 'lib/bayonet_client/exceptions.rb', line 6

def http_response_json
  @http_response_json
end

#reason_codeObject

Returns the value of attribute reason_code.



6
7
8
# File 'lib/bayonet_client/exceptions.rb', line 6

def reason_code
  @reason_code
end

#reason_messageObject

Returns the value of attribute reason_message.



6
7
8
# File 'lib/bayonet_client/exceptions.rb', line 6

def reason_message
  @reason_message
end

#request_bodyObject

Returns the value of attribute request_body.



6
7
8
# File 'lib/bayonet_client/exceptions.rb', line 6

def request_body
  @request_body
end

#request_headersObject

Returns the value of attribute request_headers.



6
7
8
# File 'lib/bayonet_client/exceptions.rb', line 6

def request_headers
  @request_headers
end