Skip to content

Commit 257fbeb

Browse files
authored
fix: print error to stdout prior to exiting (#90)
1 parent ad17f3b commit 257fbeb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

cmd/envbox/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"context"
5+
"fmt"
56
"os"
67
"os/signal"
78
"runtime"
@@ -17,8 +18,8 @@ func main() {
1718
sigs := make(chan os.Signal, 1)
1819
signal.Notify(sigs, syscall.SIGTERM, syscall.SIGINT, syscall.SIGWINCH)
1920
go func() {
20-
log := slog.Make(slogjson.Sink(os.Stderr))
2121
ctx := context.Background()
22+
log := slog.Make(slogjson.Sink(os.Stderr))
2223
log.Info(ctx, "waiting for signal")
2324
<-sigs
2425
log.Info(ctx, "got signal")
@@ -38,6 +39,7 @@ func main() {
3839
}()
3940
_, err := cli.Root(ch).ExecuteC()
4041
if err != nil {
42+
_, _ = fmt.Fprintln(os.Stderr, err.Error())
4143
os.Exit(1)
4244
}
4345
runtime.Goexit()

0 commit comments

Comments
 (0)