Skip to content

Commit

Permalink
Merge pull request #873 from dickens7/feat-wrie-errormessage
Browse files Browse the repository at this point in the history
feat: write an error message after you recover
  • Loading branch information
smallnest authored Aug 22, 2024
2 parents ee007d3 + 1d758f1 commit 0679c4a
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 @@ -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))
}
}()

Expand Down

0 comments on commit 0679c4a

Please sign in to comment.