Skip to content

Commit

Permalink
Add stack when a panic occurs
Browse files Browse the repository at this point in the history
  • Loading branch information
Roemer committed Nov 23, 2023
1 parent 9e09379 commit 7c8a789
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gotaskr.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package gotaskr
import (
"fmt"
"os/exec"
"runtime/debug"
"strings"
"time"

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 7c8a789

Please sign in to comment.