Class: RemoteResource::HTTPError

Inherits:
RemoteResourceError
  • Object
show all
Defined in:
lib/remote_resource/errors.rb

Overview

HTTP errors

Instance Method Summary collapse

Constructor Details

#initialize(request, response) ⇒ HTTPError

Returns a new instance of HTTPError.



12
13
14
15
# File 'lib/remote_resource/errors.rb', line 12

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

Instance Method Details

#http_actionObject



21
22
23
# File 'lib/remote_resource/errors.rb', line 21

def http_action
  @request.http_action
end

#request_bodyObject



33
34
35
# File 'lib/remote_resource/errors.rb', line 33

def request_body
  @request.body # TODO: Filter sensitive information using: RemoteResource::Util.filter_params
end

#request_headersObject



37
38
39
# File 'lib/remote_resource/errors.rb', line 37

def request_headers
  @request.headers
end

#request_queryObject



29
30
31
# File 'lib/remote_resource/errors.rb', line 29

def request_query
  @request.query
end

#request_urlObject



25
26
27
# File 'lib/remote_resource/errors.rb', line 25

def request_url
  @request.request_url
end

#resource_klassObject



17
18
19
# File 'lib/remote_resource/errors.rb', line 17

def resource_klass
  @request.resource_klass
end

#response_bodyObject



51
52
53
# File 'lib/remote_resource/errors.rb', line 51

def response_body
  @response.body # TODO: Filter sensitive information using: RemoteResource::Util.filter_params
end

#response_codeObject



41
42
43
# File 'lib/remote_resource/errors.rb', line 41

def response_code
  @response.code
end

#response_headersObject



55
56
57
# File 'lib/remote_resource/errors.rb', line 55

def response_headers
  @response.headers
end

#return_codeObject

The return code can contain additional information when response_code=0 see curl.se/libcurl/c/libcurl-errors.html for the full list



47
48
49
# File 'lib/remote_resource/errors.rb', line 47

def return_code
  @response.return_code
end

#to_sObject



59
60
61
62
63
64
65
66
# File 'lib/remote_resource/errors.rb', line 59

def to_s
  message = "HTTP request failed for #{resource_klass}"
  message << " with response_code=#{response_code}" if response_code.present?
  message << " with return_code=#{return_code}" if return_code.present? && response_code.zero?
  message << " with http_action=#{http_action}"
  message << " with request_url=#{request_url}"
  message
end