Author: dreiss
Date: Tue Jun 10 17:58:25 2008
New Revision: 666421

URL: http://svn.apache.org/viewvc?rev=666421&view=rev
Log:
Implement TApplicationException handling in alt_erl client

Summary:
  Throws a 'TApplicationException' record

Test plan:
  Changed cpp TestServer so that if testException is called with 
"ApplicationException" as an argument, it throws a TException which is 
serialized back as an EXCEPTION type message

Modified:
    incubator/thrift/trunk/lib/alterl/src/thrift_client.erl
    incubator/thrift/trunk/test/cpp/src/TestServer.cpp

Modified: incubator/thrift/trunk/lib/alterl/src/thrift_client.erl
URL: 
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/alterl/src/thrift_client.erl?rev=666421&r1=666420&r2=666421&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/alterl/src/thrift_client.erl (original)
+++ incubator/thrift/trunk/lib/alterl/src/thrift_client.erl Tue Jun 10 17:58:25 
2008
@@ -212,5 +212,12 @@
     Result.
                      
 
-handle_application_exception(_State) ->
-    not_yet_impl.
+handle_application_exception(State = #state{protocol = Proto}) ->
+    {ok, Exception} = thrift_protocol:read(Proto,
+                                           ?TApplicationException_Structure),
+    ok = thrift_protocol:read(Proto, message_end),
+    XRecord = list_to_tuple(
+                ['TApplicationException' | tuple_to_list(Exception)]),
+    io:format("X: ~p~n", [XRecord]),
+    true = is_record(XRecord, 'TApplicationException'),
+    {exception, XRecord}.

Modified: incubator/thrift/trunk/test/cpp/src/TestServer.cpp
URL: 
http://svn.apache.org/viewvc/incubator/thrift/trunk/test/cpp/src/TestServer.cpp?rev=666421&r1=666420&r2=666421&view=diff
==============================================================================
--- incubator/thrift/trunk/test/cpp/src/TestServer.cpp (original)
+++ incubator/thrift/trunk/test/cpp/src/TestServer.cpp Tue Jun 10 17:58:25 2008
@@ -222,13 +222,18 @@
     hello.i64_thing = (int64_t)arg2;
   }
 
-  void testException(const std::string &arg) throw(Xception) {
+  void testException(const std::string &arg)
+    throw(Xception, facebook::thrift::TException)
+  {
     printf("testException(%s)\n", arg.c_str());
     if (arg.compare("Xception") == 0) {
       Xception e;
       e.errorCode = 1001;
       e.message = "This is an Xception";
       throw e;
+    } else if (arg.compare("ApplicationException") == 0) {
+      facebook::thrift::TException e;
+      throw e;
     } else {
       Xtruct result;
       result.string_thing = arg;


Reply via email to