From 4cb35a78b0f3171cb298920a51d4c15e1ee7f26a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 30 Dec 2025 11:07:46 +0000 Subject: [PATCH] Improve CatchPanicCallback: extract context early and clarify example Co-authored-by: warkanum <208308+warkanum@users.noreply.github.com> --- pkg/logger/logger.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go index f0382d0..d1c7705 100644 --- a/pkg/logger/logger.go +++ b/pkg/logger/logger.go @@ -149,10 +149,10 @@ func Debug(template string, args ...interface{}) { // CatchPanic - Handle panic // Returns a function that should be deferred to catch panics -// Example usage: defer CatchPanicCallback("MyFunction", callback)() +// Example usage: defer CatchPanicCallback("MyFunction", func(err any) { /* cleanup */ })() func CatchPanicCallback(location string, cb func(err any), args ...interface{}) func() { + ctx, _ := extractContext(args...) return func() { - ctx, _ := extractContext(args...) if err := recover(); err != nil { callstack := debug.Stack()