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

- (Error) initialize(res)

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.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

- (Object) http_response

Returns the value of attribute http_response



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

def http_response
  @http_response
end

- (Object) message

Returns the value of attribute message



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

def message
  @message
end

- (Object) reason

Returns the value of attribute reason



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

def reason
  @reason
end

- (Object) status

Returns the value of attribute status



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

def status
  @status
end

- (Object) validations

Returns the value of attribute validations



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

def validations
  @validations
end

Instance Method Details

- (Object) to_s



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

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