THRIFT-2015 Thrift exceptions should derive from TException

Patch: Jens Geyer
diff --git a/compiler/cpp/src/generate/t_csharp_generator.cc b/compiler/cpp/src/generate/t_csharp_generator.cc
index 016e3f8..37800a5 100644
--- a/compiler/cpp/src/generate/t_csharp_generator.cc
+++ b/compiler/cpp/src/generate/t_csharp_generator.cc
@@ -514,7 +514,7 @@
   indent(out) << "public " << (is_final ? "sealed " : "") << "partial class " << tstruct->get_name() << " : ";
 
   if (is_exception) {
-    out << "Exception, ";
+    out << "TException, ";
   }
   out << "TBase";
 
@@ -997,7 +997,7 @@
 
   indent(out) << "public override void Write(TProtocol protocol) {" << endl;
   indent_up();
-  indent(out) << "throw new Exception(\"Cannot persist an union type which is not set.\");" << endl;
+  indent(out) << "throw new TProtocolException( TProtocolException.INVALID_DATA, \"Cannot persist an union type which is not set.\");" << endl;
   indent_down();
   indent(out) << "}" << endl << endl;
 
diff --git a/lib/csharp/src/Protocol/TProtocolException.cs b/lib/csharp/src/Protocol/TProtocolException.cs
index 4e4393f..bc002d3 100644
--- a/lib/csharp/src/Protocol/TProtocolException.cs
+++ b/lib/csharp/src/Protocol/TProtocolException.cs
@@ -25,7 +25,7 @@
 
 namespace Thrift.Protocol
 {
-	public class TProtocolException : Exception
+	public class TProtocolException : TException
 	{
 		public const int UNKNOWN = 0;
 		public const int INVALID_DATA = 1;
diff --git a/lib/csharp/src/TApplicationException.cs b/lib/csharp/src/TApplicationException.cs
index 9aaf6f7..4a1b2d2 100644
--- a/lib/csharp/src/TApplicationException.cs
+++ b/lib/csharp/src/TApplicationException.cs
@@ -26,7 +26,7 @@
 
 namespace Thrift
 {
-	public class TApplicationException : Exception
+	public class TApplicationException : TException
 	{
 		protected ExceptionType type;
 
diff --git a/lib/csharp/src/TException.cs b/lib/csharp/src/TException.cs
new file mode 100644
index 0000000..a99bfa8
--- /dev/null
+++ b/lib/csharp/src/TException.cs
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * Contains some contributions under the Thrift Software License.
+ * Please see doc/old-thrift-license.txt in the Thrift distribution for
+ * details.
+ */
+
+using System;
+
+namespace Thrift
+{
+	public class TException : Exception
+	{
+		public TException()
+		{
+		}
+
+		public TException( string message)
+			: base(message)
+		{
+		}
+
+	}
+}
diff --git a/lib/csharp/src/Thrift.WP7.csproj b/lib/csharp/src/Thrift.WP7.csproj
index e9dc494..2b2147e 100644
--- a/lib/csharp/src/Thrift.WP7.csproj
+++ b/lib/csharp/src/Thrift.WP7.csproj
@@ -93,6 +93,7 @@
     <Compile Include="Protocol\TSet.cs" />
     <Compile Include="Protocol\TStruct.cs" />
     <Compile Include="Protocol\TType.cs" />
+    <Compile Include="TException.cs" />
     <Compile Include="TApplicationException.cs" />
     <Compile Include="TProcessor.cs" />
     <Compile Include="Transport\TFramedTransport.cs" />
diff --git a/lib/csharp/src/Thrift.csproj b/lib/csharp/src/Thrift.csproj
index cb264c8..439b960 100644
--- a/lib/csharp/src/Thrift.csproj
+++ b/lib/csharp/src/Thrift.csproj
@@ -105,6 +105,7 @@
     <Compile Include="Server\TServer.cs" />

     <Compile Include="Server\TSimpleServer.cs" />

     <Compile Include="Server\TThreadPoolServer.cs" />

+    <Compile Include="TException.cs" />

     <Compile Include="TApplicationException.cs" />

     <Compile Include="TProcessor.cs" />

     <Compile Include="Transport\TBufferedTransport.cs" />

diff --git a/lib/csharp/src/Transport/TTransportException.cs b/lib/csharp/src/Transport/TTransportException.cs
index b96f7e8..fda0138 100644
--- a/lib/csharp/src/Transport/TTransportException.cs
+++ b/lib/csharp/src/Transport/TTransportException.cs
@@ -25,7 +25,7 @@
 
 namespace Thrift.Transport
 {
-	public class TTransportException : Exception
+	public class TTransportException : TException
 	{
 		protected ExceptionType type;