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
19 * Contains some contributions under the Thrift Software License.
20 * Please see doc/old-thrift-license.txt in the Thrift distribution for
25 using Thrift.Protocol;
29 public class TApplicationException : TException
31 protected ExceptionType type;
33 public TApplicationException()
37 public TApplicationException(ExceptionType type)
42 public TApplicationException(ExceptionType type, string message)
43 : base(message, null) // TApplicationException is serializable, but we never serialize InnerException
48 public static TApplicationException Read(TProtocol iprot)
52 string message = null;
53 ExceptionType type = ExceptionType.Unknown;
55 iprot.ReadStructBegin();
58 field = iprot.ReadFieldBegin();
59 if (field.Type == TType.Stop)
67 if (field.Type == TType.String)
69 message = iprot.ReadString();
73 TProtocolUtil.Skip(iprot, field.Type);
77 if (field.Type == TType.I32)
79 type = (ExceptionType)iprot.ReadI32();
83 TProtocolUtil.Skip(iprot, field.Type);
87 TProtocolUtil.Skip(iprot, field.Type);
94 iprot.ReadStructEnd();
96 return new TApplicationException(type, message);
99 public void Write(TProtocol oprot)
101 TStruct struc = new TStruct("TApplicationException");
102 TField field = new TField();
104 oprot.WriteStructBegin(struc);
106 if (!string.IsNullOrEmpty(Message))
108 field.Name = "message";
109 field.Type = TType.String;
111 oprot.WriteFieldBegin(field);
112 oprot.WriteString(Message);
113 oprot.WriteFieldEnd();
117 field.Type = TType.I32;
119 oprot.WriteFieldBegin(field);
120 oprot.WriteI32((int)type);
121 oprot.WriteFieldEnd();
122 oprot.WriteFieldStop();
123 oprot.WriteStructEnd();
126 public enum ExceptionType
138 UnsupportedClientType
141 public ExceptionType Type