Exception: Riak::ProtobuffsFailedRequest
- Inherits:
-
FailedRequest
- Object
- StandardError
- FailedRequest
- Riak::ProtobuffsFailedRequest
- Defined in:
- lib/riak/failed_request.rb
Overview
Exception raised when receiving an unexpected Protocol Buffers response from Riak
Instance Method Summary collapse
-
#initialize(code, message) ⇒ ProtobuffsFailedRequest
constructor
A new instance of ProtobuffsFailedRequest.
-
#is_json? ⇒ true, false
Whether the error response is in JSON.
-
#not_found? ⇒ true, false
Whether the error represents a “not found” response.
-
#server_error? ⇒ true, false
Whether the error represents an internal server error.
Methods included from Util::Translation
Constructor Details
#initialize(code, message) ⇒ ProtobuffsFailedRequest
Returns a new instance of ProtobuffsFailedRequest.
53 54 55 56 57 58 |
# File 'lib/riak/failed_request.rb', line 53 def initialize(code, ) super t('protobuffs_failed_request', :code => code, :body => ) @original_message = @not_found = code == :not_found @server_error = code == :server_error end |
Instance Method Details
#is_json? ⇒ true, false
Returns whether the error response is in JSON.
61 62 63 64 65 66 67 68 |
# File 'lib/riak/failed_request.rb', line 61 def is_json? begin JSON.parse() true rescue false end end |
#not_found? ⇒ true, false
Returns whether the error represents a “not found” response.
71 72 73 |
# File 'lib/riak/failed_request.rb', line 71 def not_found? @not_found end |
#server_error? ⇒ true, false
Returns whether the error represents an internal server error.
77 78 79 |
# File 'lib/riak/failed_request.rb', line 77 def server_error? @server_error end |