From 7c8a789b88815976086354a2230cc48136129a1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20B=C3=A4riswyl?= Date: Thu, 23 Nov 2023 11:29:12 +0100 Subject: [PATCH] Add stack when a panic occurs --- gotaskr.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gotaskr.go b/gotaskr.go index 376eedb..c899667 100644 --- a/gotaskr.go +++ b/gotaskr.go @@ -5,6 +5,7 @@ package gotaskr import ( "fmt" "os/exec" + "runtime/debug" "strings" "time" @@ -263,7 +264,7 @@ func runTaskFunc(currentTask *TaskObject) (err error) { func runFuncRecover(function func() error) (err error) { defer func() { if r := recover(); r != nil { - err = fmt.Errorf("task panicked: %v", r) + err = fmt.Errorf("task panicked: %v\nStack:\n%s", r, debug.Stack()) } }() err = function()