log panics

This commit is contained in:
Asim Aslam 2017-05-16 19:14:00 +01:00
parent 4cb22b5969
commit a7312f5c7e
3 changed files with 4 additions and 3 deletions

View File

@ -98,7 +98,7 @@ func (r *rpcClient) call(ctx context.Context, address string, req Request, resp
go func() { go func() {
defer func() { defer func() {
if r := recover(); r != nil { 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))
} }
}() }()

View File

@ -53,7 +53,8 @@ func (s *rpcServer) accept(sock transport.Socket) {
sock.Close() sock.Close()
if r := recover(); r != nil { if r := recover(); r != nil {
log.Log(r, string(debug.Stack())) log.Log("panic recovered: ", r)
log.Log(string(debug.Stack()))
} }
}() }()

View File

@ -319,7 +319,7 @@ func (h *httpTransportListener) Accept(fn func(Socket)) error {
// TODO: think of a better error response strategy // TODO: think of a better error response strategy
defer func() { defer func() {
if r := recover(); r != nil { if r := recover(); r != nil {
log.Logf("http: recovered %v", r) log.Log("panic recovered: ", r)
sock.Close() sock.Close()
} }
}() }()