Skip to content
This repository
Browse code

Log stacktrace during error

The Type/Reason for an error are almost always useless.  I had to
dynamically trace the module just so I could find out why the tests
were failing.  Include the stacktrace so when users have errors we can
actually diagnose them.  Removed some of the lager calls because SASL
will already log on non-normal stop.
  • Loading branch information...
commit 18d3d9f92e4d7b149923b254f42ff90f482c8124 1 parent b4092bc
Ryan Zezeski authored June 05, 2012

Showing 1 changed file with 12 additions and 11 deletions. Show diff stats Hide diff stats

  1. 23  src/riak_api_pb_server.erl
23  src/riak_api_pb_server.erl
@@ -135,9 +135,10 @@ handle_info({tcp, _Sock, [MsgCode|MsgData]}, State=#state{
135 135
     catch
136 136
         %% Tell the client we errored before closing the connection.
137 137
         Type:Failure ->
138  
-            lager:debug("Message processing error: ~p:~p ~p", [Type, Failure, erlang:get_stacktrace()]),
139  
-            send_error("Error processing incoming message: ~p:~p", [Type, Failure], State),
140  
-            {stop, {Type, Failure}, State}
  138
+            Trace = erlang:get_stacktrace(),
  139
+            send_error("Error processing incoming message: ~p:~p:~p",
  140
+                       [Type, Failure, Trace], State),
  141
+            {stop, {Type, Failure, Trace}, State}
141 142
     end
142 143
 ;
143 144
 handle_info({tcp, _Sock, _Data}, State) ->
@@ -160,15 +161,14 @@ handle_info(StreamMessage, #state{req={Service,ReqId},
160 161
     catch
161 162
         %% Tell the client we errored before closing the connection.
162 163
         Type:Reason ->
163  
-            lager:debug("Streaming message processing error (State: ~p): ~p:~p ~p",
164  
-                        [State, Type, Reason, erlang:get_stacktrace()]),
165  
-            send_error("Error processing stream message: ~p:~p", [Type, Reason], State),
166  
-            {stop, {Type, Reason}, State}
  164
+            Trace = erlang:get_stacktrace(),
  165
+            send_error("Error processing stream message: ~p:~p:~p",
  166
+                       [Type, Reason, Trace], State),
  167
+            {stop, {Type, Reason, Trace}, State}
167 168
     end;
168 169
 handle_info(Message, State) ->
169  
-    %% Throw out messages we don't care about, but log them at the
170  
-    %% debug level.
171  
-    lager:debug("Unrecognized message ~p", [Message]),
  170
+    %% Throw out messages we don't care about, but log them
  171
+    lager:error("Unrecognized message ~p", [Message]),
172 172
     {noreply, State}.
173 173
 
174 174
 
@@ -265,7 +265,8 @@ send_encoded_message_or_error(Service, ReplyMessage, ServerState) ->
265 265
         {ok, Encoded} ->
266 266
             send_message(Encoded, ServerState);
267 267
         Error ->
268  
-            lager:debug("PB service ~p could not encode message ~p: ~p", [Service, ReplyMessage, Error]),
  268
+            lager:error("PB service ~p could not encode message ~p: ~p",
  269
+                        [Service, ReplyMessage, Error]),
269 270
             send_error("Internal service error: no encoding for response message", ServerState)
270 271
     end.
271 272
 

0 notes on commit 18d3d9f

Please sign in to comment.
Something went wrong with that request. Please try again.