[thrift] make Erlang server noisy when handler has error
authorChristopher Piro <cpiro@apache.org>
Wed, 1 Aug 2007 23:42:12 +0000 (23:42 +0000)
committerChristopher Piro <cpiro@apache.org>
Wed, 1 Aug 2007 23:42:12 +0000 (23:42 +0000)
Summary: generate an error message at the server ... before only the client got the error

Reviewed By: iproctor

Test Plan: tutorial, channel server

Revert Plan: ok

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665187 13f79535-47bb-0310-9956-ffa450edef68

lib/erl/lib/thrift/src/transport/tErlAcceptor.erl
lib/erl/lib/thrift/src/transport/tSocket.erl

index 3407c82..8093e00 100644 (file)
@@ -8,6 +8,7 @@
 
 -include("oop.hrl").
 -include("thrift.hrl").
+-include("tApplicationException.hrl").
 -include("transport/tTransportException.hrl").
 -include("transport/tServerSocket.hrl").
 -include("transport/tErlAcceptor.hrl").
@@ -100,10 +101,14 @@ accept(This, ListenSocket, GP, Handler) ->
     end.
 
 receive_loop(This, Processor, Iprot, Oprot) ->
-    try
-       Value = ?R2(Processor, process, Iprot, Oprot),
-       ?INFO(req_processed, {Value}),
-       receive_loop(This, Processor, Iprot, Oprot)
+    try ?R2(Processor, process, Iprot, Oprot) of
+       {error, TAE} when is_record(TAE, tApplicationException),
+                         TAE#tApplicationException.type == ?tApplicationException_HANDLER_ERROR ->
+           ?ERROR("handler returned an error: ~p", [oop:get(TAE, message)]),
+           receive_loop(This, Processor, Iprot, Oprot);
+       Value ->
+           ?INFO(req_processed, {Value}),
+           receive_loop(This, Processor, Iprot, Oprot)
     catch
        %% the following clause must be last because we might reexit
        %% cpiro: breaks if it's a subclass of tTransportException
index dd1ff9b..491d86b 100644 (file)
@@ -15,7 +15,7 @@
 
 -behavior(oop).
 
--export([attr/4, super/0, inspect/1, catches/2]).
+-export([attr/4, super/0, inspect/1]).
 
 -export([new/0, new/1, new/2, 
         effectful_setHandle/2, effectful_open/1,