Exception: Rested::Error

Inherits:
Exception
  • Object
show all
Defined in:
lib/rested/error.rb

Direct Known Subclasses

ObjectNotFound

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(res) ⇒ 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.message = 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_responseObject

Returns the value of attribute http_response



6
7
8
# File 'lib/rested/error.rb', line 6

def http_response
  @http_response
end

#messageObject

Returns the value of attribute message



6
7
8
# File 'lib/rested/error.rb', line 6

def message
  @message
end

#reasonObject

Returns the value of attribute reason



6
7
8
# File 'lib/rested/error.rb', line 6

def reason
  @reason
end

#statusObject

Returns the value of attribute status



6
7
8
# File 'lib/rested/error.rb', line 6

def status
  @status
end

#validationsObject

Returns the value of attribute validations



6
7
8
# File 'lib/rested/error.rb', line 6

def validations
  @validations
end

Instance Method Details

#to_sObject



21
22
23
# File 'lib/rested/error.rb', line 21

def to_s
    "#{self.status} #{self.reason}" + (self.message.nil? ? "" : ": #{self.message}")
end