Exception: Riak::ProtobuffsFailedRequest
- Inherits:
-
FailedRequest
- Object
- StandardError
- Error
- FailedRequest
- Riak::ProtobuffsFailedRequest
- Defined in:
- lib/riak/errors/failed_request.rb
Overview
Exception raised when receiving an unexpected Protocol Buffers response from Riak
Direct Known Subclasses
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#original_message ⇒ Object
readonly
Returns the value of attribute original_message.
Instance Method Summary collapse
- #body ⇒ Object
-
#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.
13 14 15 16 17 18 19 |
# File 'lib/riak/errors/failed_request.rb', line 13 def initialize(code, ) super t('protobuffs_failed_request', :code => code, :body => ) @original_message = @code = code @not_found = code == :not_found @server_error = code == :server_error end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
12 13 14 |
# File 'lib/riak/errors/failed_request.rb', line 12 def code @code end |
#original_message ⇒ Object (readonly)
Returns the value of attribute original_message.
12 13 14 |
# File 'lib/riak/errors/failed_request.rb', line 12 def @original_message end |
Instance Method Details
#body ⇒ Object
42 43 44 |
# File 'lib/riak/errors/failed_request.rb', line 42 def body @original_message end |
#is_json? ⇒ true, false
Returns whether the error response is in JSON.
22 23 24 25 26 27 28 29 |
# File 'lib/riak/errors/failed_request.rb', line 22 def is_json? begin JSON.parse(@original_message) true rescue false end end |
#not_found? ⇒ true, false
Returns whether the error represents a “not found” response.
32 33 34 |
# File 'lib/riak/errors/failed_request.rb', line 32 def not_found? @not_found end |
#server_error? ⇒ true, false
Returns whether the error represents an internal server error.
38 39 40 |
# File 'lib/riak/errors/failed_request.rb', line 38 def server_error? @server_error end |