Skip to content

Commit 0679c4a

Browse files
authored
Merge pull request #873 from dickens7/feat-wrie-errormessage
feat: write an error message after you recover
2 parents ee007d3 + 1d758f1 commit 0679c4a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

โ€Žserver/server.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,13 @@ func (s *Server) processOneRequest(ctx *share.Context, req *protocol.Message, co
533533
if r := recover(); r != nil {
534534
buf := make([]byte, 1024)
535535
buf = buf[:runtime.Stack(buf, true)]
536-
537-
log.Errorf("failed to handle the request: %v๏ผŒ stacks: %s", r, buf)
536+
if s.HandleServiceError != nil {
537+
s.HandleServiceError(fmt.Errorf("%v", r))
538+
} else {
539+
log.Errorf("[handler internal error]: servicepath: %s, servicemethod, err: %v๏ผŒstacks: %s", req.ServicePath, req.ServiceMethod, r, buf)
540+
}
541+
sctx := NewContext(ctx, conn, req, s.AsyncWrite)
542+
sctx.WriteError(fmt.Errorf("%v", r))
538543
}
539544
}()
540545

0 commit comments

Comments
ย (0)