Exception: Thrift::ApplicationException

Inherits:
Exception
  • Object
show all
Defined in:
lib/thrift/exceptions.rb

Constant Summary collapse

UNKNOWN =
0
UNKNOWN_METHOD =
1
INVALID_MESSAGE_TYPE =
2
WRONG_METHOD_NAME =
3
BAD_SEQUENCE_ID =
4
MISSING_RESULT =
5

Instance Attribute Summary collapse

Attributes inherited from Exception

#message

Instance Method Summary collapse

Constructor Details

#initialize(type = UNKNOWN, message = nil) ⇒ ApplicationException

Returns a new instance of ApplicationException.



23
24
25
26
# File 'lib/thrift/exceptions.rb', line 23

def initialize(type=UNKNOWN, message=nil)
  super(message)
  @type = type
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



21
22
23
# File 'lib/thrift/exceptions.rb', line 21

def type
  @type
end

Instance Method Details

#read(iprot) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/thrift/exceptions.rb', line 28

def read(iprot)
  iprot.read_struct_begin
  while true
    fname, ftype, fid = iprot.read_field_begin
    if ftype == Types::STOP
      break
    end
    if fid == 1 and ftype == Types::STRING
      @message = iprot.read_string
    elsif fid == 2 and ftype == Types::I32
      @type = iprot.read_i32
    else
      iprot.skip(ftype)
    end
    iprot.read_field_end
  end
  iprot.read_struct_end
end

#write(oprot) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/thrift/exceptions.rb', line 47

def write(oprot)
  oprot.write_struct_begin('Thrift::ApplicationException')
  unless @message.nil?
    oprot.write_field_begin('message', Types::STRING, 1)
    oprot.write_string(@message)
    oprot.write_field_end
  end
  unless @type.nil?
    oprot.write_field_begin('type', Types::I32, 2)
    oprot.write_i32(@type)
    oprot.write_field_end
  end
  oprot.write_field_stop
  oprot.write_struct_end
end