Class: Cql::Protocol::DetailedErrorResponse

Inherits:
ErrorResponse show all
Defined in:
lib/cql/protocol/responses/detailed_error_response.rb

Instance Attribute Summary collapse

Attributes inherited from ErrorResponse

#code, #message

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Decoding

#read_byte!, #read_bytes!, #read_consistency!, #read_decimal!, #read_double!, #read_float!, #read_inet!, #read_int!, #read_long!, #read_long_string!, #read_option!, #read_short!, #read_short_bytes!, #read_string!, #read_string_list!, #read_string_map!, #read_string_multimap!, #read_uuid!, #read_varint!

Constructor Details

#initialize(code, message, details) ⇒ DetailedErrorResponse

Returns a new instance of DetailedErrorResponse.



8
9
10
11
# File 'lib/cql/protocol/responses/detailed_error_response.rb', line 8

def initialize(code, message, details)
  super(code, message)
  @details = details
end

Instance Attribute Details

#detailsObject (readonly)

Returns the value of attribute details.



6
7
8
# File 'lib/cql/protocol/responses/detailed_error_response.rb', line 6

def details
  @details
end

Class Method Details

.decode!(code, message, buffer) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cql/protocol/responses/detailed_error_response.rb', line 13

def self.decode!(code, message, buffer)
  details = {}
  case code
  when 0x1000 # unavailable
    details[:cl] = read_consistency!(buffer)
    details[:required] = read_int!(buffer)
    details[:alive] = read_int!(buffer)
  when 0x1100 # write_timeout
    details[:cl] = read_consistency!(buffer)
    details[:received] = read_int!(buffer)
    details[:blockfor] = read_int!(buffer)
    details[:write_type] = read_string!(buffer)
  when 0x1200 # read_timeout
    details[:cl] = read_consistency!(buffer)
    details[:received] = read_int!(buffer)
    details[:blockfor] = read_int!(buffer)
    details[:data_present] = read_byte!(buffer) != 0
  when 0x2400 # already_exists
    details[:ks] = read_string!(buffer)
    details[:table] = read_string!(buffer)
  when 0x2500
    details[:id] = read_short_bytes!(buffer)
  end
  new(code, message, details)
end

Instance Method Details

#to_sObject



39
40
41
# File 'lib/cql/protocol/responses/detailed_error_response.rb', line 39

def to_s
  %(ERROR #@code "#@message" #@details)
end