Exception: Riak::ProtobuffsFailedRequest

Inherits:
FailedRequest show all
Defined in:
lib/riak/failed_request.rb

Overview

Exception raised when receiving an unexpected Protocol Buffers response from Riak

Instance Method Summary collapse

Methods included from Util::Translation

#i18n_scope, #t

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, message)
  super t('protobuffs_failed_request', :code => code, :body => message)
  @original_message = 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.

Returns:

  • (true, false)

    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(original_message)
    true
  rescue
    false
  end
end

#not_found?true, false

Returns whether the error represents a “not found” response.

Returns:

  • (true, false)

    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.

Returns:

  • (true, false)

    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