File tree Expand file tree Collapse file tree 1 file changed +11
-13
lines changed
Expand file tree Collapse file tree 1 file changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -11,13 +11,13 @@ import (
1111 "runtime/debug"
1212 "strings"
1313
14+ "github.com/sirupsen/logrus"
15+
1416 "github.com/yuaotian/go-cursor-help/internal/config"
1517 "github.com/yuaotian/go-cursor-help/internal/lang"
1618 "github.com/yuaotian/go-cursor-help/internal/process"
1719 "github.com/yuaotian/go-cursor-help/internal/ui"
1820 "github.com/yuaotian/go-cursor-help/pkg/idgen"
19-
20- "github.com/sirupsen/logrus"
2121)
2222
2323// Global variables
2929)
3030
3131func main () {
32- setupErrorRecovery ()
32+ // Place defer at the beginning of main to ensure it can catch panics from all subsequent function calls
33+ defer func () {
34+ if r := recover (); r != nil {
35+ log .Errorf ("Panic recovered: %v\n " , r )
36+ debug .PrintStack ()
37+ waitExit ()
38+ }
39+ }()
40+
3341 handleFlags ()
3442 setupLogger ()
3543
@@ -73,16 +81,6 @@ func main() {
7381 }
7482}
7583
76- func setupErrorRecovery () {
77- defer func () {
78- if r := recover (); r != nil {
79- log .Errorf ("Panic recovered: %v\n " , r )
80- debug .PrintStack ()
81- waitExit ()
82- }
83- }()
84- }
85-
8684func handleFlags () {
8785 flag .Parse ()
8886 if * showVersion {
You can’t perform that action at this time.
0 commit comments