Exception: Ya::API::Direct::RequestError
- Inherits:
-
StandardError
- Object
- StandardError
- Ya::API::Direct::RequestError
- Defined in:
- lib/ya/api/direct/exceptions.rb
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(method:, version:, request:, response:) ⇒ RequestError
constructor
A new instance of RequestError.
- #to_s ⇒ Object
Constructor Details
#initialize(method:, version:, request:, response:) ⇒ RequestError
Returns a new instance of RequestError.
19 20 21 22 23 24 |
# File 'lib/ya/api/direct/exceptions.rb', line 19 def initialize( method: , version: , request: , response: ) @method = method @version = version @request = request @response = response end |
Instance Attribute Details
#method ⇒ Object (readonly)
Returns the value of attribute method.
17 18 19 |
# File 'lib/ya/api/direct/exceptions.rb', line 17 def method @method end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
17 18 19 |
# File 'lib/ya/api/direct/exceptions.rb', line 17 def request @request end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
17 18 19 |
# File 'lib/ya/api/direct/exceptions.rb', line 17 def response @response end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
17 18 19 |
# File 'lib/ya/api/direct/exceptions.rb', line 17 def version @version end |
Instance Method Details
#to_s ⇒ Object
26 27 28 29 30 31 |
# File 'lib/ya/api/direct/exceptions.rb', line 26 def to_s if response.body && ['text/json', 'application/json'].include?( response["Content-Type"] ) && error = JSON.parse( response.body )['error'] err_msg = error.values_at('error_code', 'error_string', 'error_detail', 'request_id').reject(&:blank?).join(' : ') end [ ['HTTP ', response.code].join, err_msg ].compact.join(': ') end |