Skip to content

Commit 30a299a

Browse files
authored
Merge pull request #616 from DefangLabs/lio-track-panics
Track CLI panics
2 parents 9708723 + 56bd0e3 commit 30a299a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/cmd/cli/main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,21 @@ import (
44
"context"
55
"os"
66
"os/signal"
7+
"runtime/debug"
78

89
"github.com/DefangLabs/defang/src/cmd/cli/command"
910
"github.com/DefangLabs/defang/src/pkg/term"
1011
)
1112

1213
func main() {
14+
defer func() {
15+
if r := recover(); r != nil {
16+
command.Track("Panic", command.P{"error", r}, command.P{"stack", string(debug.Stack())})
17+
command.FlushAllTracking()
18+
panic(r)
19+
}
20+
}()
21+
1322
// Handle Ctrl+C so we can exit gracefully
1423
ctx, cancel := context.WithCancel(context.Background())
1524
sigs := make(chan os.Signal, 1)

0 commit comments

Comments
 (0)