Exception: ApiResource::ConnectionError
- Inherits:
-
StandardError
- Object
- StandardError
- ApiResource::ConnectionError
- Defined in:
- lib/api_resource/exceptions.rb
Overview
:nodoc:
Direct Known Subclasses
ClientError, Redirection, RequestTimeout, SSLError, ServerError
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #http_code ⇒ Object
-
#initialize(response, options = {}) ⇒ ConnectionError
constructor
A new instance of ConnectionError.
- #to_s ⇒ Object
Constructor Details
#initialize(response, options = {}) ⇒ ConnectionError
Returns a new instance of ConnectionError.
8 9 10 11 12 |
# File 'lib/api_resource/exceptions.rb', line 8 def initialize(response, = {}) @response = response @message = [:message] @path = [:path] end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
6 7 8 |
# File 'lib/api_resource/exceptions.rb', line 6 def response @response end |
Instance Method Details
#http_code ⇒ Object
34 35 36 |
# File 'lib/api_resource/exceptions.rb', line 34 def http_code self.class.http_code end |
#to_s ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/api_resource/exceptions.rb', line 14 def to_s = "Failed." if response.respond_to?(:code) << " Response code = #{response.code}." end if response.respond_to?(:body) begin body = JSON.parse(response.body).pretty_inspect rescue body = "INVALID JSON: #{response.body}" end << "\nResponse message = #{body}." end << "\n#{@message}" << "\n#{@path}" end |