]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/thrift/lib/as3/src/org/apache/thrift/TApplicationError.as
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / thrift / lib / as3 / src / org / apache / thrift / TApplicationError.as
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 package org.apache.thrift {
21
22 import org.apache.thrift.protocol.TField;
23 import org.apache.thrift.protocol.TProtocol;
24 import org.apache.thrift.protocol.TProtocolUtil;
25 import org.apache.thrift.protocol.TStruct;
26 import org.apache.thrift.protocol.TType;
27
28 /**
29 * Application level exception
30 */
31 public class TApplicationError extends TError {
32
33 private static const TAPPLICATION_EXCEPTION_STRUCT:TStruct = new TStruct("TApplicationException");
34 private static const MESSAGE_FIELD:TField = new TField("message", TType.STRING, 1);
35 private static const TYPE_FIELD:TField = new TField("type", TType.I32, 2);
36
37 public static const UNKNOWN:int = 0;
38 public static const UNKNOWN_METHOD:int = 1;
39 public static const INVALID_MESSAGE_TYPE:int = 2;
40 public static const WRONG_METHOD_NAME:int = 3;
41 public static const BAD_SEQUENCE_ID:int = 4;
42 public static const MISSING_RESULT:int = 5;
43 public static const INTERNAL_ERROR:int = 6;
44 public static const PROTOCOL_ERROR:int = 7;
45 public static const INVALID_TRANSFORM:int = 8;
46 public static const INVALID_PROTOCOL:int = 9;
47 public static const UNSUPPORTED_CLIENT_TYPE:int = 10;
48
49 public function TApplicationError(type:int = UNKNOWN, message:String = "") {
50 super(message, type);
51 }
52
53 public static function read(iprot:TProtocol):TApplicationError {
54 var field:TField;
55 iprot.readStructBegin();
56
57 var message:String = null;
58 var type:int = UNKNOWN;
59
60 while (true) {
61 field = iprot.readFieldBegin();
62 if (field.type == TType.STOP) {
63 break;
64 }
65 switch (field.id) {
66 case 1:
67 if (field.type == TType.STRING) {
68 message = iprot.readString();
69 }
70 else {
71 TProtocolUtil.skip(iprot, field.type);
72 }
73 break;
74 case 2:
75 if (field.type == TType.I32) {
76 type = iprot.readI32();
77 }
78 else {
79 TProtocolUtil.skip(iprot, field.type);
80 }
81 break;
82 default:
83 TProtocolUtil.skip(iprot, field.type);
84 break;
85 }
86 iprot.readFieldEnd();
87 }
88 iprot.readStructEnd();
89 return new TApplicationError(type, message);
90 }
91
92 public function write(oprot:TProtocol):void {
93 oprot.writeStructBegin(TAPPLICATION_EXCEPTION_STRUCT);
94 if (message != null) {
95 oprot.writeFieldBegin(MESSAGE_FIELD);
96 oprot.writeString(message);
97 oprot.writeFieldEnd();
98 }
99 oprot.writeFieldBegin(TYPE_FIELD);
100 oprot.writeI32(errorID);
101 oprot.writeFieldEnd();
102 oprot.writeFieldStop();
103 oprot.writeStructEnd();
104 }
105 }
106 }