Skip to content

Commit

Permalink
feat: write an error message after you recover
Browse files Browse the repository at this point in the history
  • Loading branch information
lixiangyang committed Aug 22, 2024
1 parent 6663fb7 commit 1d758f1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,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))
}
}()

Expand Down

0 comments on commit 1d758f1

Please sign in to comment.