Exception: Riak::HTTPFailedRequest
- Inherits:
-
FailedRequest
- Object
- StandardError
- FailedRequest
- Riak::HTTPFailedRequest
- Defined in:
- riak-client/lib/riak/failed_request.rb
Overview
Exception raised when the expected HTTP response code from Riak fails to match the actual response code.
Instance Attribute Summary (collapse)
-
- (String) body
readonly
The response body, if present.
-
- (Fixnum) code
readonly
The received response code.
-
- (Fixnum) expected
readonly
The expected response code.
-
- (Hash) headers
readonly
The response headers.
-
- (Symbol) method
readonly
The HTTP method, one of :head, :get, :post, :put, :delete.
Instance Method Summary (collapse)
-
- (HTTPFailedRequest) initialize(method, expected_code, received_code, headers, body)
constructor
A new instance of HTTPFailedRequest.
- - (Boolean) is_json?
-
- (true, false) not_found?
Whether the error represents a “not found” response.
-
- (true, false) server_error?
Whether the error represents an internal server error.
Methods included from Util::Translation
Constructor Details
- (HTTPFailedRequest) initialize(method, expected_code, received_code, headers, body)
A new instance of HTTPFailedRequest
43 44 45 46 |
# File 'riak-client/lib/riak/failed_request.rb', line 43 def initialize(method, expected_code, received_code, headers, body) @method, @expected, @code, @headers, @body = method, expected_code, received_code, headers, body super t("http_failed_request", :expected => @expected.inspect, :code => @code, :body => @body) end |
Instance Attribute Details
- (String) body (readonly)
The response body, if present
41 42 43 |
# File 'riak-client/lib/riak/failed_request.rb', line 41 def body @body end |
- (Fixnum) code (readonly)
The received response code
37 38 39 |
# File 'riak-client/lib/riak/failed_request.rb', line 37 def code @code end |
- (Fixnum) expected (readonly)
The expected response code
35 36 37 |
# File 'riak-client/lib/riak/failed_request.rb', line 35 def expected @expected end |
- (Hash) headers (readonly)
The response headers
39 40 41 |
# File 'riak-client/lib/riak/failed_request.rb', line 39 def headers @headers end |
- (Symbol) method (readonly)
The HTTP method, one of :head, :get, :post, :put, :delete
33 34 35 |
# File 'riak-client/lib/riak/failed_request.rb', line 33 def method @method end |
Instance Method Details
- (Boolean) is_json?
48 49 50 |
# File 'riak-client/lib/riak/failed_request.rb', line 48 def is_json? headers['content-type'].include?('application/json') end |
- (true, false) not_found?
Whether the error represents a “not found” response
53 54 55 |
# File 'riak-client/lib/riak/failed_request.rb', line 53 def not_found? @code.to_i == 404 end |
- (true, false) server_error?
Whether the error represents an internal server error
59 60 61 |
# File 'riak-client/lib/riak/failed_request.rb', line 59 def server_error? @code.to_i == 500 end |