Exception: RestfulResource::HttpClient::HttpError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/restful_resource/http_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request, response = nil) ⇒ HttpError

Returns a new instance of HttpError.



9
10
11
12
# File 'lib/restful_resource/http_client.rb', line 9

def initialize(request, response = nil)
  @request = request
  @response = assign_response(response)
end

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request.



7
8
9
# File 'lib/restful_resource/http_client.rb', line 7

def request
  @request
end

#responseObject (readonly)

Returns the value of attribute response.



7
8
9
# File 'lib/restful_resource/http_client.rb', line 7

def response
  @response
end

Instance Method Details

#assign_response(response = nil) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/restful_resource/http_client.rb', line 14

def assign_response(response = nil)
  @response = if response
                Response.new(body: response[:body], headers: response[:headers], status: response[:status])
              else
                Response.new
              end
end