Exception: Rested::Error
- Inherits:
-
Exception
- Object
- Exception
- Rested::Error
- Defined in:
- lib/rested/error.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#http_response ⇒ Object
Returns the value of attribute http_response.
-
#message ⇒ Object
Returns the value of attribute message.
-
#reason ⇒ Object
Returns the value of attribute reason.
-
#status ⇒ Object
Returns the value of attribute status.
-
#validations ⇒ Object
Returns the value of attribute validations.
Instance Method Summary collapse
-
#initialize(res) ⇒ Error
constructor
A new instance of Error.
- #to_s ⇒ Object
Constructor Details
#initialize(res) ⇒ Error
Returns a new instance of Error.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rested/error.rb', line 8 def initialize(res) hash = Rested::Base.decode_response(res) if hash.include? "error" then self. = hash["error"] end self.validations = Validations.new(hash['validations']) self.status = res.status self.reason = res.reason self.http_response = res end |
Instance Attribute Details
#http_response ⇒ Object
Returns the value of attribute http_response.
6 7 8 |
# File 'lib/rested/error.rb', line 6 def http_response @http_response end |
#message ⇒ Object
Returns the value of attribute message.
6 7 8 |
# File 'lib/rested/error.rb', line 6 def @message end |
#reason ⇒ Object
Returns the value of attribute reason.
6 7 8 |
# File 'lib/rested/error.rb', line 6 def reason @reason end |
#status ⇒ Object
Returns the value of attribute status.
6 7 8 |
# File 'lib/rested/error.rb', line 6 def status @status end |
#validations ⇒ Object
Returns the value of attribute validations.
6 7 8 |
# File 'lib/rested/error.rb', line 6 def validations @validations end |
Instance Method Details
#to_s ⇒ Object
21 22 23 |
# File 'lib/rested/error.rb', line 21 def to_s "#{self.status} #{self.reason}" + (self..nil? ? "" : ": #{self.}") end |