You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: error.go
    path of file: ./repos/pyroscope/pkg/util/http
    
    the code of the file until where you have to start completion: package http

import (
	"context"
	"encoding/json"
	"errors"
	"net/http"

	"connectrpc.com/connect"
	"github.com/grafana/dskit/httpgrpc"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"

	"github.com/grafana/pyroscope/pkg/tenant"
	"github.com/grafana/pyroscope/pkg/util/connectgrpc"
)

var errorWriter = conne
    
func ErrorWithStatus(w http.ResponseWriter, err error, status int) {
	w.Header().Set("X-Content-Type-Options", "nosniff")
	w.Header().Set("Content-Type", "application/json")

	w.WriteHeader(status)
	if err := json.NewEncoder(w).Encode(struct {
		Code    connect.Code `json:"code"`
		Message string       `json:"message"`
	}{
		Code:    connectgrpc.HTTPToCode(int32(status)),
		Message: err.Error(),
	}); err != nil {
		http.Error(w, err.Error(), status)
	}
}