Skip to content

Commit

Permalink
add traceId for error output (#234)
Browse files Browse the repository at this point in the history
Co-authored-by: shi yuhang <52435083+shiyuhang0@users.noreply.github.com>
  • Loading branch information
zhangyangyu and shiyuhang0 authored Sep 9, 2024
1 parent 6e2a6b0 commit c72cbe4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/service/cloud/api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,9 +615,13 @@ func parseError(err error, resp *http.Response) error {
if err1 != nil {
return err
}
path := "[path]"
path := "<path>"
if resp.Request != nil {
path = fmt.Sprintf("[%s %s]", resp.Request.Method, resp.Request.URL.Path)
}
return fmt.Errorf("%s[%s] %s", path, err.Error(), body)
traceId := "<trace_id>"
if resp.Header.Get("X-Debug-Trace-Id") != "" {
traceId = resp.Header.Get("X-Debug-Trace-Id")
}
return fmt.Errorf("%s[%s][%s] %s", path, err.Error(), traceId, body)
}

0 comments on commit c72cbe4

Please sign in to comment.