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: responses.go
    path of file: ./repos/dapr/pkg/api/http
    
    the code of the file until where you have to start completion: /*
Copyright 2021 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the 
    
func respondWithError(w http.ResponseWriter, err error) {
	if err == nil {
		return
	}

	// Check if it's an APIError object
	apiErr, ok := err.(messages.APIError)
	if ok {
		respondWithData(w, apiErr.HTTPCode(), apiErr.JSONErrorValue())
		return
	}

	// Check if it's a kitErrors.Error object
	if kitErr, ok := kitErrors.FromError(err); ok {
		respondWithData(w, kitErr.HTTPStatusCode(), kitErr.JSONErrorValue())
		return
	}

	// Respond with a generic error
	msg := NewErrorResponse("ERROR", err.Error())
	respondWithData(w, http.StatusInternalServerError, msg.JSONErrorValue())
}