]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/thrift/lib/perl/lib/Thrift/Exception.pm
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / jaegertracing / thrift / lib / perl / lib / Thrift / Exception.pm
CommitLineData
f67539c2
TL
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
20use 5.10.0;
21use strict;
22use warnings;
23
24use Thrift;
25use Thrift::Type;
26
27package Thrift::TException;
28use version 0.77; our $VERSION = version->declare("$Thrift::VERSION");
29
30use overload '""' => sub {
31 return
32 sprintf '%s error: %s (code %s)',
33 ref( $_[0] ),
34 ( $_[0]->{message} || 'empty message' ),
35 ( defined $_[0]->{code} ? $_[0]->{code} : 'undefined' );
36 };
37
38sub new {
39 my $classname = shift;
40 my $self = {message => shift, code => shift || 0};
41
42 return bless($self,$classname);
43}
44
45package Thrift::TApplicationException;
46use parent -norequire, 'Thrift::TException';
47use version 0.77; our $VERSION = version->declare("$Thrift::VERSION");
48
49use constant UNKNOWN => 0;
50use constant UNKNOWN_METHOD => 1;
51use constant INVALID_MESSAGE_TYPE => 2;
52use constant WRONG_METHOD_NAME => 3;
53use constant BAD_SEQUENCE_ID => 4;
54use constant MISSING_RESULT => 5;
55use constant INTERNAL_ERROR => 6;
56use constant PROTOCOL_ERROR => 7;
57use constant INVALID_TRANSFORM => 8;
58use constant INVALID_PROTOCOL => 9;
59use constant UNSUPPORTED_CLIENT_TYPE => 10;
60
61sub new {
62 my $classname = shift;
63
64 my $self = $classname->SUPER::new(@_);
65
66 return bless($self,$classname);
67}
68
69sub read {
70 my $self = shift;
71 my $input = shift;
72
73 my $xfer = 0;
74 my $fname = undef;
75 my $ftype = 0;
76 my $fid = 0;
77
78 $xfer += $input->readStructBegin(\$fname);
79
80 while (1)
81 {
82 $xfer += $input->readFieldBegin(\$fname, \$ftype, \$fid);
83 if ($ftype == Thrift::TType::STOP) {
84 last; next;
85 }
86
87 SWITCH: for($fid)
88 {
89 /1/ && do{
90
91 if ($ftype == Thrift::TType::STRING) {
92 $xfer += $input->readString(\$self->{message});
93 }
94 else {
95 $xfer += $input->skip($ftype);
96 }
97
98 last;
99 };
100
101 /2/ && do{
102 if ($ftype == Thrift::TType::I32) {
103 $xfer += $input->readI32(\$self->{code});
104 }
105 else {
106 $xfer += $input->skip($ftype);
107 }
108 last;
109 };
110
111 $xfer += $input->skip($ftype);
112 }
113
114 $xfer += $input->readFieldEnd();
115 }
116 $xfer += $input->readStructEnd();
117
118 return $xfer;
119}
120
121sub write {
122 my $self = shift;
123 my $output = shift;
124
125 my $xfer = 0;
126
127 $xfer += $output->writeStructBegin('TApplicationException');
128
129 if ($self->getMessage()) {
130 $xfer += $output->writeFieldBegin('message', Thrift::TType::STRING, 1);
131 $xfer += $output->writeString($self->getMessage());
132 $xfer += $output->writeFieldEnd();
133 }
134
135 if ($self->getCode()) {
136 $xfer += $output->writeFieldBegin('type', Thrift::TType::I32, 2);
137 $xfer += $output->writeI32($self->getCode());
138 $xfer += $output->writeFieldEnd();
139 }
140
141 $xfer += $output->writeFieldStop();
142 $xfer += $output->writeStructEnd();
143
144 return $xfer;
145}
146
147sub getMessage
148{
149 my $self = shift;
150
151 return $self->{message};
152}
153
154sub getCode
155{
156 my $self = shift;
157
158 return $self->{code};
159}
160
1611;