Exception: Nestful::ResponseError
- Defined in:
- lib/nestful/exceptions.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Attributes inherited from Error
Instance Method Summary collapse
-
#initialize(request, response, message = nil) ⇒ ResponseError
constructor
A new instance of ResponseError.
- #to_s ⇒ Object
Constructor Details
#initialize(request, response, message = nil) ⇒ ResponseError
Returns a new instance of ResponseError.
17 18 19 20 |
# File 'lib/nestful/exceptions.rb', line 17 def initialize(request, response, = nil) super(request, ) @response = response end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
15 16 17 |
# File 'lib/nestful/exceptions.rb', line 15 def response @response end |
Instance Method Details
#to_s ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/nestful/exceptions.rb', line 22 def to_s = "Failed." << " Response code = #{response.code}." if response.respond_to?(:code) << " Response message = #{response.}." if response.respond_to?(:message) if response.respond_to?(:body) # Error messages need to be in UTF-8 body = response.body.dup.to_s body = body.encode('UTF-8', :invalid => :replace, :undef => :replace, :replace => '?') body = body[0..255] << " Response Body = #{body}." end end |