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
10 * http://www.apache.org/licenses/LICENSE-2.0
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
20 package org.apache.thrift {
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;
29 * Application level exception
31 public class TApplicationError extends TError {
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);
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;
49 public function TApplicationError(type:int = UNKNOWN, message:String = "") {
53 public static function read(iprot:TProtocol):TApplicationError {
55 iprot.readStructBegin();
57 var message:String = null;
58 var type:int = UNKNOWN;
61 field = iprot.readFieldBegin();
62 if (field.type == TType.STOP) {
67 if (field.type == TType.STRING) {
68 message = iprot.readString();
71 TProtocolUtil.skip(iprot, field.type);
75 if (field.type == TType.I32) {
76 type = iprot.readI32();
79 TProtocolUtil.skip(iprot, field.type);
83 TProtocolUtil.skip(iprot, field.type);
88 iprot.readStructEnd();
89 return new TApplicationError(type, message);
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();
99 oprot.writeFieldBegin(TYPE_FIELD);
100 oprot.writeI32(errorID);
101 oprot.writeFieldEnd();
102 oprot.writeFieldStop();
103 oprot.writeStructEnd();