Exception: Simple::HTTP::Error

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/simple/http/errors.rb

Direct Known Subclasses

TooManyRedirections

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, request, response) ⇒ Error

Returns a new instance of Error.



12
13
14
# File 'lib/simple/http/errors.rb', line 12

def initialize(method, request, response)
  @method, @request, @response = method, request, response
end

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



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

def method
  @method
end

#requestObject (readonly)

Returns the value of attribute request.



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

def request
  @request
end

#responseObject (readonly)

Returns the value of attribute response.



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

def response
  @response
end

Instance Method Details

#codeObject



16
17
18
# File 'lib/simple/http/errors.rb', line 16

def code
  response.code.to_i
end

#messageObject



20
21
22
23
24
25
26
# File 'lib/simple/http/errors.rb', line 20

def message
  message = "#{method} #{response.uri} ##{response.code} #{response.message}"
  if response.is_a?(Net::HTTPRedirection)
    message += " To #{response["Location"]}"
  end
  message
end