Skip to content

Commit e21af05

Browse files
author
zhailongtao
committed
opt: output detailed stack trace information when a panic occurs.
1 parent 4fb3b98 commit e21af05

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

executor.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package gocron
33
import (
44
"context"
55
"fmt"
6+
"runtime/debug"
67
"strconv"
78
"sync"
89
"time"
@@ -448,6 +449,7 @@ func (e *executor) callJobWithRecover(j internalJob) (err error) {
448449
if recoverData := recover(); recoverData != nil {
449450
_ = callJobFuncWithParams(j.afterJobRunsWithPanic, j.id, j.name, recoverData)
450451

452+
e.logger.Error("gocron: panic occurred", "jobID", j.id, "jobName", j.name, "stack", string(debug.Stack()))
451453
// if panic is occurred, we should return an error
452454
err = fmt.Errorf("%w from %v", ErrPanicRecovered, recoverData)
453455
}

0 commit comments

Comments
 (0)