2 // TApplicationException.cs
6 // Todd Berman <tberman@imeem.com>
8 // Distributed under the Thrift Software License
10 // See accompanying file LICENSE or visit the Thrift site at:
11 // http://developers.facebook.com/thrift/using
14 using System
.Collections
.Generic
;
16 using Thrift
.Protocol
;
20 public class TApplicationException
: Exception
22 protected ExceptionType type
;
24 public TApplicationException()
28 public TApplicationException(ExceptionType type
)
33 public TApplicationException(ExceptionType type
, string message
)
39 public static TApplicationException
Read(TProtocol iprot
)
42 TStruct struc
= iprot
.ReadStructBegin();
44 string message
= null;
45 ExceptionType type
= ExceptionType
.Unknown
;
49 field
= iprot
.ReadFieldBegin();
50 if (field
.Type
== TType
.Stop
)
58 if (field
.Type
== TType
.String
)
60 message
= iprot
.ReadString();
64 TProtocolUtil
.Skip(iprot
, field
.Type
);
68 if (field
.Type
== TType
.I32
)
70 type
= (ExceptionType
)iprot
.ReadI32();
74 TProtocolUtil
.Skip(iprot
, field
.Type
);
78 TProtocolUtil
.Skip(iprot
, field
.Type
);
85 iprot
.ReadStructEnd();
87 return new TApplicationException(type
, message
);
90 public void Write(TProtocol oprot
)
92 TStruct struc
= new TStruct("TApplicationException");
93 TField field
= new TField();
95 oprot
.WriteStructBegin(struc
);
97 if (!String
.IsNullOrEmpty(Message
))
99 field
.Name
= "message";
100 field
.Type
= TType
.String
;
102 oprot
.WriteFieldBegin(field
);
103 oprot
.WriteString(Message
);
104 oprot
.WriteFieldEnd();
108 field
.Type
= TType
.I32
;
110 oprot
.WriteFieldBegin(field
);
111 oprot
.WriteI32((int)type
);
112 oprot
.WriteFieldEnd();
113 oprot
.WriteFieldStop();
114 oprot
.WriteStructEnd();
117 public enum ExceptionType