]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | /// Licensed to the Apache Software Foundation (ASF) under one |
2 | /// or more contributor license agreements. See the NOTICE file | |
3 | /// distributed with this work for additional information | |
4 | /// regarding copyright ownership. The ASF licenses this file | |
5 | /// to you under the Apache License, Version 2.0 (the | |
6 | /// "License"); you may not use this file except in compliance | |
7 | /// with the License. You may obtain a copy of the License at | |
8 | /// | |
9 | /// http://www.apache.org/licenses/LICENSE-2.0 | |
10 | /// | |
11 | /// Unless required by applicable law or agreed to in writing, | |
12 | /// software distributed under the License is distributed on an | |
13 | /// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
14 | /// KIND, either express or implied. See the License for the | |
15 | /// specific language governing permissions and limitations | |
16 | /// under the License. | |
17 | ||
18 | part of thrift; | |
19 | ||
20 | class TApplicationErrorType { | |
21 | static const int UNKNOWN = 0; | |
22 | static const int UNKNOWN_METHOD = 1; | |
23 | static const int INVALID_MESSAGE_TYPE = 2; | |
24 | static const int WRONG_METHOD_NAME = 3; | |
25 | static const int BAD_SEQUENCE_ID = 4; | |
26 | static const int MISSING_RESULT = 5; | |
27 | static const int INTERNAL_ERROR = 6; | |
28 | static const int PROTOCOL_ERROR = 7; | |
29 | static const int INVALID_TRANSFORM = 8; | |
30 | static const int INVALID_PROTOCOL = 9; | |
31 | static const int UNSUPPORTED_CLIENT_TYPE = 10; | |
32 | } | |
33 | ||
34 | class TApplicationError extends TError { | |
35 | static final TStruct _struct = new TStruct("TApplicationError"); | |
36 | static const int MESSAGE = 1; | |
37 | static final TField _messageField = | |
38 | new TField("message", TType.STRING, MESSAGE); | |
39 | static const int TYPE = 2; | |
40 | static final TField _typeField = new TField("type", TType.I32, TYPE); | |
41 | ||
42 | TApplicationError( | |
43 | [int type = TApplicationErrorType.UNKNOWN, String message = ""]) | |
44 | : super(type, message); | |
45 | ||
46 | static TApplicationError read(TProtocol iprot) { | |
47 | TField field; | |
48 | ||
49 | String message = null; | |
50 | int type = TApplicationErrorType.UNKNOWN; | |
51 | ||
52 | iprot.readStructBegin(); | |
53 | while (true) { | |
54 | field = iprot.readFieldBegin(); | |
55 | ||
56 | if (field.type == TType.STOP) { | |
57 | break; | |
58 | } | |
59 | ||
60 | switch (field.id) { | |
61 | case MESSAGE: | |
62 | if (field.type == TType.STRING) { | |
63 | message = iprot.readString(); | |
64 | } else { | |
65 | TProtocolUtil.skip(iprot, field.type); | |
66 | } | |
67 | break; | |
68 | ||
69 | case TYPE: | |
70 | if (field.type == TType.I32) { | |
71 | type = iprot.readI32(); | |
72 | } else { | |
73 | TProtocolUtil.skip(iprot, field.type); | |
74 | } | |
75 | break; | |
76 | ||
77 | default: | |
78 | TProtocolUtil.skip(iprot, field.type); | |
79 | break; | |
80 | } | |
81 | iprot.readFieldEnd(); | |
82 | } | |
83 | iprot.readStructEnd(); | |
84 | ||
85 | return new TApplicationError(type, message); | |
86 | } | |
87 | ||
88 | write(TProtocol oprot) { | |
89 | oprot.writeStructBegin(_struct); | |
90 | ||
91 | if (message != null && !message.isEmpty) { | |
92 | oprot.writeFieldBegin(_messageField); | |
93 | oprot.writeString(message); | |
94 | oprot.writeFieldEnd(); | |
95 | } | |
96 | ||
97 | oprot.writeFieldBegin(_typeField); | |
98 | oprot.writeI32(type); | |
99 | oprot.writeFieldEnd(); | |
100 | ||
101 | oprot.writeFieldStop(); | |
102 | oprot.writeStructEnd(); | |
103 | } | |
104 | } |