Skip to content

Commit

Permalink
Removed named return parameter to make sure we don't forget setting it
Browse files Browse the repository at this point in the history
Signed-off-by: Marco Pracucci <marco@pracucci.com>
  • Loading branch information
pracucci committed Jun 18, 2024
1 parent b20987d commit 793436b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pkg/frontend/transport/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ func formatRequestHeaders(h *http.Header, headersToLog []string) (fields []any)
}

// writeError writes the error response to http.ResponseWriter, and returns the response HTTP status code.
func writeError(w http.ResponseWriter, err error) (statusCode int) {
func writeError(w http.ResponseWriter, err error) int {
switch {
case errors.Is(err, context.Canceled):
err = errCanceled
Expand All @@ -456,16 +456,15 @@ func writeError(w http.ResponseWriter, err error) (statusCode int) {
// If we've been able to get the HTTP response from the error, then we send
// it with the right status code and response body content.
if resFound {
statusCode = int(res.Code)
_ = httpgrpc.WriteResponse(w, res)
return
return int(res.Code)
}

// Otherwise, we do fallback to a 5xx error, returning the non-formatted error
// message in the response body.
statusCode = http.StatusInternalServerError
statusCode := http.StatusInternalServerError
http.Error(w, err.Error(), statusCode)
return
return statusCode
}

func writeServiceTimingHeader(queryResponseTime time.Duration, headers http.Header, stats *querier_stats.Stats) {
Expand Down

0 comments on commit 793436b

Please sign in to comment.