in funcframework/framework.go [382:399]
func writeHTTPErrorResponse(w http.ResponseWriter, statusCode int, status, msg string) {
// Ensure logs end with a newline otherwise they are grouped incorrectly in SD.
if !strings.HasSuffix(msg, "\n") {
msg += "\n"
}
fmt.Fprint(os.Stderr, msg)
// Flush stdout and stderr when running on GCF. This must be done before writing
// the HTTP response in order for all logs to appear in GCF.
if os.Getenv("K_SERVICE") != "" {
fmt.Println()
fmt.Fprintln(os.Stderr)
}
w.Header().Set(functionStatusHeader, status)
w.WriteHeader(statusCode)
fmt.Fprint(w, msg)
}