添加世界运行异常时的堆栈打印

This commit is contained in:
walker 2023-10-19 13:12:45 +08:00
parent 37e06d2aaf
commit 0eb750b76a

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"log/slog" "log/slog"
"math" "math"
"runtime/debug"
"time" "time"
"github.com/yohamta/donburi" "github.com/yohamta/donburi"
@ -219,6 +220,8 @@ func (w *world) run() {
defer func() { defer func() {
if err := recover(); err != nil { if err := recover(); err != nil {
w.exception(err) w.exception(err)
slog.Error("世界运行异常", "error", err, "stack", string(debug.Stack()))
debug.PrintStack()
} }
}() }()
for range w.ticker.C { for range w.ticker.C {