Skip to content

Commit 87c20e7

Browse files
committed
Debug trace at /debug/500
1 parent 7308b1a commit 87c20e7

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

internal/api/handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,8 +714,8 @@ func NewHandler(staticDir fs.FS, jsSettings JSSettings, showInvisible bool, chV1
714714
return h, nil
715715
}
716716

717-
func (h *Handler) savePanic(requestURI string, err any, stack []byte) {
718-
v := error500{time: time.Now(), requestURI: requestURI, what: err, stack: stack}
717+
func (h *requestHandler) savePanic(requestURI string, err any, stack []byte) {
718+
v := error500{time: time.Now(), requestURI: requestURI, what: err, stack: stack, trace: h.trace}
719719
h.errorsMu.Lock()
720720
h.errors[h.errorX] = v
721721
h.errorX = (h.errorX + 1) % len(h.errors)

internal/api/http_router.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ type error500 struct {
5555
requestURI string
5656
what any
5757
stack []byte
58+
trace []string
5859
}
5960

6061
func NewHTTPRouter(h *Handler) httpRouter {
@@ -173,7 +174,12 @@ func DumpInternalServerErrors(r *httpRequestHandler) {
173174
w.Write([]byte("# " + r.errors[i].requestURI + " \n"))
174175
w.Write([]byte(fmt.Sprintf("# %s \n", r.errors[i].what)))
175176
w.Write([]byte("# " + r.errors[i].time.Format(time.RFC3339) + " \n"))
176-
w.Write([]byte("# \n"))
177+
w.Write([]byte("# debug trace\n"))
178+
for _, v := range r.errors[i].trace {
179+
w.Write([]byte(v))
180+
w.Write([]byte("\n"))
181+
}
182+
w.Write([]byte("# stack trace\n"))
177183
w.Write(r.errors[i].stack)
178184
w.Write([]byte("\n"))
179185
}

0 commit comments

Comments
 (0)