Thrift-1441: Generate constructor with parameters for exception class to let it update message property automatically.
Client:delphi
Patch: Kenjiro Fukumitsu

Add the function to delphi generator that generates constructor with parameters to initialize members,if the class is exception and have more than zero parameters.



git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1212226 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/delphi/test/TestServer.pas b/lib/delphi/test/TestServer.pas
index 26d49d2..8f890da 100644
--- a/lib/delphi/test/TestServer.pas
+++ b/lib/delphi/test/TestServer.pas
@@ -106,17 +106,11 @@
 end;
 
 procedure TTestServer.TTestHandlerImpl.testException(arg: string);
-var
-  x : TXception;
 begin
   Console.WriteLine('testException(' + arg + ')');
   if ( arg = 'Xception') then
   begin
-    x := TXception.Create;
-    x.ErrorCode := 1001;
-    x.Message_ := 'This is an Xception';
-    x.UpdateMessageProperty;
-    raise x;
+    raise TXception.Create( 1001, 'This is an Xception');
   end;
 end;
 
@@ -272,21 +266,16 @@
 function TTestServer.TTestHandlerImpl.testMultiException(arg0,
   arg1: string): IXtruct;
 var
-  x : TXception;
   x2 : TXception2;
 begin
   Console.WriteLine('testMultiException(' + arg0 + ', ' + arg1 + ')');
   if ( arg0 = 'Xception') then
   begin
-    x := TXception.Create;
-    x.ErrorCode := 1001;
-    x.Message_ := 'This is an Xception';
-    x.UpdateMessageProperty;
-    raise x;
+    raise TXception.Create( 1001, 'This is an Xception');  // test the new rich CTOR 
   end else
   if ( arg0 = 'Xception2') then
   begin
-    x2 := TXception2.Create;
+    x2 := TXception2.Create;  // the old way still works too?
     x2.ErrorCode := 2002;
     x2.Struct_thing := TXtructImpl.Create;
     x2.Struct_thing.String_thing := 'This is an Xception2';