Skip to content

Commit

Permalink
Include stack explicitly in panic recovery log
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Sep 30, 2024
1 parent ff99cb8 commit a4a5665
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion utils/crons/cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func fireCron(rt *runtime.Runtime, name string, cronFunc Function, timeout time.
if panicVal := recover(); panicVal != nil {
debug.PrintStack()

slog.Error("panic running cron", "cron", name, "panic", panicVal)
slog.Error("panic running cron", "cron", name, "value", panicVal, "stack", debug.Stack())
}
}()

Expand Down
2 changes: 1 addition & 1 deletion web/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func panicRecovery(next http.Handler) http.Handler {
if panicVal := recover(); panicVal != nil {
debug.PrintStack()

slog.Error("panic in web handling", "url", r.URL.String(), "panic", panicVal)
slog.Error("panic in web handling", "url", r.URL.String(), "value", panicVal, "stack", debug.Stack())

http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
}
Expand Down
2 changes: 1 addition & 1 deletion workers.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (w *Worker) handleTask(task *queues.Task) {
if panicVal := recover(); panicVal != nil {
debug.PrintStack()

log.Error("panic handling task", "task", string(task.Task), "panic", panicVal)
log.Error("panic handling task", "task", string(task.Task), "value", panicVal, "stack", debug.Stack())
}

// mark our task as complete
Expand Down

0 comments on commit a4a5665

Please sign in to comment.