mirror of
https://github.com/smallnest/rpcx.git
synced 2025-12-24 12:27:56 +08:00
Merge pull request #873 from dickens7/feat-wrie-errormessage
feat: write an error message after you recover
This commit is contained in:
@@ -533,8 +533,13 @@ func (s *Server) processOneRequest(ctx *share.Context, req *protocol.Message, co
|
||||
if r := recover(); r != nil {
|
||||
buf := make([]byte, 1024)
|
||||
buf = buf[:runtime.Stack(buf, true)]
|
||||
|
||||
log.Errorf("failed to handle the request: %v, stacks: %s", r, buf)
|
||||
if s.HandleServiceError != nil {
|
||||
s.HandleServiceError(fmt.Errorf("%v", r))
|
||||
} else {
|
||||
log.Errorf("[handler internal error]: servicepath: %s, servicemethod, err: %v,stacks: %s", req.ServicePath, req.ServiceMethod, r, buf)
|
||||
}
|
||||
sctx := NewContext(ctx, conn, req, s.AsyncWrite)
|
||||
sctx.WriteError(fmt.Errorf("%v", r))
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user