Exception: Rest::HttpError

Inherits:
RestError
  • Object
show all
Defined in:
lib/rest/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, code, options = {}) ⇒ HttpError

Returns a new instance of HttpError.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rest/errors.rb', line 13

def initialize(response, code, options={})
  super("#{code} Error")
  @response = response
  if response && response.body 
    begin
      bodyparsed = JSON.parse(response.body)
      @msg = bodyparsed["msg"]
    rescue => ex
      # ignore
    end  
  end
  @code = code
  @options = options
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



10
11
12
# File 'lib/rest/errors.rb', line 10

def code
  @code
end

#msgObject

Returns the value of attribute msg.



11
12
13
# File 'lib/rest/errors.rb', line 11

def msg
  @msg
end

#optionsObject

Returns the value of attribute options.



11
12
13
# File 'lib/rest/errors.rb', line 11

def options
  @options
end

#responseObject (readonly)

Returns the value of attribute response.



10
11
12
# File 'lib/rest/errors.rb', line 10

def response
  @response
end

Instance Method Details

#to_sObject



28
29
30
31
32
33
34
# File 'lib/rest/errors.rb', line 28

def to_s
  s = "HTTP #{code} Error"
  if @msg
    s += ": #{@msg}"
  end
  s
end