Commit 11f50f41 authored by Dmitry Vyukov's avatar Dmitry Vyukov

cmd/trace: log errors to console in AJAX handler

Fixes #11508

Change-Id: I72e83893b76f75685d6edfe65ca6691d97539226
Reviewed-on: https://go-review.googlesource.com/11864Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 2a0fc9e7
......@@ -8,6 +8,7 @@ import (
"encoding/json"
"fmt"
"internal/trace"
"log"
"net/http"
"os"
"path/filepath"
......@@ -67,9 +68,10 @@ func httpTraceViewerHTML(w http.ResponseWriter, r *http.Request) {
// httpJsonTrace serves json trace, requested from within templTrace HTML.
func httpJsonTrace(w http.ResponseWriter, r *http.Request) {
// This is an AJAX handler, so instead of http.Error we use log.Printf to log errors.
events, err := parseEvents()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
log.Printf("failed to parse trace: %v", err)
return
}
......@@ -81,7 +83,7 @@ func httpJsonTrace(w http.ResponseWriter, r *http.Request) {
if goids := r.FormValue("goid"); goids != "" {
goid, err := strconv.ParseUint(goids, 10, 64)
if err != nil {
http.Error(w, fmt.Sprintf("failed to parse goid parameter '%v': %v", goids, err), http.StatusInternalServerError)
log.Printf("failed to parse goid parameter '%v': %v", goids, err)
return
}
analyzeGoroutines(events)
......@@ -95,7 +97,7 @@ func httpJsonTrace(w http.ResponseWriter, r *http.Request) {
err = json.NewEncoder(w).Encode(generateTrace(params))
if err != nil {
http.Error(w, fmt.Sprintf("failed to serialize trace: %v", err), http.StatusInternalServerError)
log.Printf("failed to serialize trace: %v", err)
return
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment