RuntimeCallerStack returns the app's `file:line` stacktrace to give more information about an error cause.
()
| 23 | // RuntimeCallerStack returns the app's `file:line` stacktrace |
| 24 | // to give more information about an error cause. |
| 25 | func RuntimeCallerStack() (s string) { |
| 26 | var pcs [10]uintptr |
| 27 | n := runtime.Callers(1, pcs[:]) |
| 28 | frames := runtime.CallersFrames(pcs[:n]) |
| 29 | |
| 30 | for { |
| 31 | frame, more := frames.Next() |
| 32 | for _, fn := range validStackFuncs { |
| 33 | if fn(frame.File) { |
| 34 | s += fmt.Sprintf("\n\t\t\t%s:%d", frame.File, frame.Line) |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | if !more { |
| 39 | break |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | return s |
| 44 | } |
| 45 | |
| 46 | // HTTPError describes an HTTP error. |
| 47 | type HTTPError struct { |