Exception: BayonetClient::BayonetError
- Inherits:
-
Exception
- Object
- Exception
- BayonetClient::BayonetError
- Defined in:
- lib/bayonet_client/exceptions.rb
Instance Attribute Summary collapse
-
#http_response_code ⇒ Object
Returns the value of attribute http_response_code.
-
#http_response_json ⇒ Object
Returns the value of attribute http_response_json.
-
#reason_code ⇒ Object
Returns the value of attribute reason_code.
-
#reason_message ⇒ Object
Returns the value of attribute reason_message.
-
#request_body ⇒ Object
Returns the value of attribute request_body.
-
#request_headers ⇒ Object
Returns the value of attribute request_headers.
Instance Method Summary collapse
-
#initialize(request_body, request_headers, http_response_code, http_response_json, reason_code = nil, reason_message = nil) ⇒ BayonetError
constructor
A new instance of BayonetError.
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, = 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. = # 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. = http_response_json['reason_message'] end if http_response_json.class == HTTParty::Response && http_response_json.key?('status') self. = http_response_json['status'] self.reason_code = -1 end end |
Instance Attribute Details
#http_response_code ⇒ Object
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_json ⇒ Object
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_code ⇒ Object
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_message ⇒ Object
Returns the value of attribute reason_message.
6 7 8 |
# File 'lib/bayonet_client/exceptions.rb', line 6 def end |
#request_body ⇒ Object
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_headers ⇒ Object
Returns the value of attribute request_headers.
6 7 8 |
# File 'lib/bayonet_client/exceptions.rb', line 6 def request_headers @request_headers end |