method
handle_response
rails latest stable - Class:
ActiveResource::Connection
Method deprecated or moved
This method is deprecated or moved on the latest stable version. The last existing version (v3.2.13) is shown here.
handle_response(response)private
Handles response and error codes from the remote service.
# File activeresource/lib/active_resource/connection.rb, line 123
def handle_response(response)
case response.code.to_i
when 301, 302, 303, 307
raise(Redirection.new(response))
when 200...400
response
when 400
raise(BadRequest.new(response))
when 401
raise(UnauthorizedAccess.new(response))
when 403
raise(ForbiddenAccess.new(response))
when 404
raise(ResourceNotFound.new(response))
when 405
raise(MethodNotAllowed.new(response))
when 409
raise(ResourceConflict.new(response))
when 410
raise(ResourceGone.new(response))
when 422
raise(ResourceInvalid.new(response))
when 401...500
raise(ClientError.new(response))
when 500...600
raise(ServerError.new(response))
else
raise(ConnectionError.new(response, "Unknown response code: #{response.code}"))
end
end Related methods
- Instance methods
- auth_type=
- delete
- get
- head
- password=
- post
- proxy=
- put
- site=
- ssl_options=
- timeout=
- user=
- Class methods
- new
- requests
- Private methods
-
apply_ssl_options -
auth_attributes_for -
authorization_header -
build_request_headers -
client_nonce -
configure_http -
default_header -
digest_auth_header -
extract_params_from_response -
handle_response -
http -
http_format_header -
legitimize_auth_type -
new_http -
request -
response_auth_header -
with_auth