PrintStack prints the error stack to w.
(w io.Writer, err error)
| 24 | |
| 25 | // PrintStack prints the error stack to w. |
| 26 | func PrintStack(w io.Writer, err error) { |
| 27 | for i, err := range errors.Stack(err) { |
| 28 | if i == 0 { |
| 29 | fmt.Fprintln(w, err) |
| 30 | } else { |
| 31 | fmt.Fprintf(w, "--- %s\n", err) |
| 32 | } |
| 33 | for k, v := range errors.Attributes(err) { |
| 34 | fmt.Fprintf(os.Stderr, " %s=%v\n", k, v) |
| 35 | } |
| 36 | if ttnErr, ok := errors.From(err); ok { |
| 37 | if correlationID := ttnErr.CorrelationID(); correlationID != "" { |
| 38 | fmt.Fprintf(os.Stderr, " correlation_id=%s\n", ttnErr.CorrelationID()) |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | } |
no test coverage detected