Skip to content

Commit

Permalink
log panics
Browse files Browse the repository at this point in the history
  • Loading branch information
Asim Aslam committed May 16, 2017
1 parent 4cb22b5 commit a7312f5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion client/rpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}()

Expand Down
3 changes: 2 additions & 1 deletion server/rpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}
}()

Expand Down
2 changes: 1 addition & 1 deletion transport/http_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}()
Expand Down

0 comments on commit a7312f5

Please sign in to comment.