Skip to content

Commit

Permalink
🧹 Capture underlying error on codes.DataLoss
Browse files Browse the repository at this point in the history
We are throwing away the underlying error. Capturing it to better
understand why this happens
  • Loading branch information
jaym committed Sep 16, 2024
1 parent 97927b1 commit 071b1f4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,12 @@ func (s *server) ServeHTTP(w http.ResponseWriter, req *http.Request) {
// preProcessRequest is used to preprocess the incoming request.
// It returns the context, a cancel function and the body of the request. The cancel function can be used to cancel
// the context. It also adds the http headers to the context.
func preProcessRequest(ctx context.Context, req *http.Request) (context.Context, context.CancelFunc, []byte, error) {
func preProcessRequest(ctx context.Context, span trace.Span, req *http.Request) (context.Context, context.CancelFunc, []byte, error) {
// read body content
body, err := io.ReadAll(req.Body)
defer req.Body.Close()
if err != nil {
span.RecordError(err)
return nil, nil, nil, status.Error(codes.DataLoss, "unrecoverable data loss or corruption")
}

Expand Down

0 comments on commit 071b1f4

Please sign in to comment.