Exception: RestClient::RequestFailed

Inherits:
Exception
  • Object
show all
Defined in:
lib/vendor/rest-client/lib/rest_client/request_errors.rb

Overview

The request failed, meaning the remote HTTP server returned a code other than success, unauthorized, or redirect.

The exception message attempts to extract the error from the XML, using format returned by Rails: <errors><error>some message</error></errors>

You can get the status code by e.http_code, or see anything about the response via e.response. For example, the entire result body (which is probably an HTML error page) is e.response.body.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response = nil) ⇒ RequestFailed

Returns a new instance of RequestFailed.



52
53
54
# File 'lib/vendor/rest-client/lib/rest_client/request_errors.rb', line 52

def initialize(response=nil)
	@response = response
end

Instance Attribute Details

#responseObject

Returns the value of attribute response.



50
51
52
# File 'lib/vendor/rest-client/lib/rest_client/request_errors.rb', line 50

def response
  @response
end

Instance Method Details

#http_codeObject



56
57
58
# File 'lib/vendor/rest-client/lib/rest_client/request_errors.rb', line 56

def http_code
	@response.code.to_i if @response
end

#messageObject



60
61
62
# File 'lib/vendor/rest-client/lib/rest_client/request_errors.rb', line 60

def message
	"HTTP status code #{http_code}"
end

#to_sObject



64
65
66
# File 'lib/vendor/rest-client/lib/rest_client/request_errors.rb', line 64

def to_s
	message
end