From a7312f5c7e2c93a1476317ec853fa5b04b00496e Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Tue, 16 May 2017 19:14:00 +0100 Subject: [PATCH] log panics --- client/rpc_client.go | 2 +- server/rpc_server.go | 3 ++- transport/http_transport.go | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/client/rpc_client.go b/client/rpc_client.go index 17c3e34f..cc4078bd 100644 --- a/client/rpc_client.go +++ b/client/rpc_client.go @@ -98,7 +98,7 @@ func (r *rpcClient) call(ctx context.Context, address string, req Request, resp go func() { defer func() { if r := recover(); r != nil { - ch <- errors.InternalServerError("go.micro.client", "request error") + ch <- errors.InternalServerError("go.micro.client", fmt.Sprintf("panic recovered: %v", r)) } }() diff --git a/server/rpc_server.go b/server/rpc_server.go index c71902c4..6f97ab9c 100644 --- a/server/rpc_server.go +++ b/server/rpc_server.go @@ -53,7 +53,8 @@ func (s *rpcServer) accept(sock transport.Socket) { sock.Close() if r := recover(); r != nil { - log.Log(r, string(debug.Stack())) + log.Log("panic recovered: ", r) + log.Log(string(debug.Stack())) } }() diff --git a/transport/http_transport.go b/transport/http_transport.go index a17548f2..e3ab5eb9 100644 --- a/transport/http_transport.go +++ b/transport/http_transport.go @@ -319,7 +319,7 @@ func (h *httpTransportListener) Accept(fn func(Socket)) error { // TODO: think of a better error response strategy defer func() { if r := recover(); r != nil { - log.Logf("http: recovered %v", r) + log.Log("panic recovered: ", r) sock.Close() } }()