]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/thrift/lib/rb/lib/thrift/exceptions.rb
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / thrift / lib / rb / lib / thrift / exceptions.rb
1 #
2 # Licensed to the Apache Software Foundation (ASF) under one
3 # or more contributor license agreements. See the NOTICE file
4 # distributed with this work for additional information
5 # regarding copyright ownership. The ASF licenses this file
6 # to you under the Apache License, Version 2.0 (the
7 # "License"); you may not use this file except in compliance
8 # with the License. You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing,
13 # software distributed under the License is distributed on an
14 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 # KIND, either express or implied. See the License for the
16 # specific language governing permissions and limitations
17 # under the License.
18 #
19
20 module Thrift
21 class Exception < StandardError
22 def initialize(message)
23 super
24 @message = message
25 end
26
27 attr_reader :message
28 end
29
30 class ApplicationException < Exception
31
32 UNKNOWN = 0
33 UNKNOWN_METHOD = 1
34 INVALID_MESSAGE_TYPE = 2
35 WRONG_METHOD_NAME = 3
36 BAD_SEQUENCE_ID = 4
37 MISSING_RESULT = 5
38 INTERNAL_ERROR = 6
39 PROTOCOL_ERROR = 7
40 INVALID_TRANSFORM = 8
41 INVALID_PROTOCOL = 9
42 UNSUPPORTED_CLIENT_TYPE = 10
43
44 attr_reader :type
45
46 def initialize(type=UNKNOWN, message=nil)
47 super(message)
48 @type = type
49 end
50
51 def read(iprot)
52 iprot.read_struct_begin
53 while true
54 fname, ftype, fid = iprot.read_field_begin
55 if ftype == Types::STOP
56 break
57 end
58 if fid == 1 and ftype == Types::STRING
59 @message = iprot.read_string
60 elsif fid == 2 and ftype == Types::I32
61 @type = iprot.read_i32
62 else
63 iprot.skip(ftype)
64 end
65 iprot.read_field_end
66 end
67 iprot.read_struct_end
68 end
69
70 def write(oprot)
71 oprot.write_struct_begin('Thrift::ApplicationException')
72 unless @message.nil?
73 oprot.write_field_begin('message', Types::STRING, 1)
74 oprot.write_string(@message)
75 oprot.write_field_end
76 end
77 unless @type.nil?
78 oprot.write_field_begin('type', Types::I32, 2)
79 oprot.write_i32(@type)
80 oprot.write_field_end
81 end
82 oprot.write_field_stop
83 oprot.write_struct_end
84 end
85
86 end
87 end