From: Christopher Piro Date: Wed, 1 Aug 2007 23:42:12 +0000 (+0000) Subject: [thrift] make Erlang server noisy when handler has error X-Git-Tag: 0.2.0~1285 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=c3c6c0c9c4dc77c6b2b7dce952eeb2fe69513a40;p=common%2Fthrift.git [thrift] make Erlang server noisy when handler has error 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 --- diff --git a/lib/erl/lib/thrift/src/transport/tErlAcceptor.erl b/lib/erl/lib/thrift/src/transport/tErlAcceptor.erl index 3407c82c..8093e00c 100644 --- a/lib/erl/lib/thrift/src/transport/tErlAcceptor.erl +++ b/lib/erl/lib/thrift/src/transport/tErlAcceptor.erl @@ -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 diff --git a/lib/erl/lib/thrift/src/transport/tSocket.erl b/lib/erl/lib/thrift/src/transport/tSocket.erl index dd1ff9b0..491d86b6 100644 --- a/lib/erl/lib/thrift/src/transport/tSocket.erl +++ b/lib/erl/lib/thrift/src/transport/tSocket.erl @@ -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,