Skip to content

Commit 4b8b811

Browse files
cx-dmitri-rivincx-anurag-dalke
authored andcommitted
double errors handled.
1 parent 6408e9e commit 4b8b811

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

cmd/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ func exitIfError(err error) {
146146
if err != nil {
147147
switch e := err.(type) {
148148
case *wrappers.AstError:
149-
fmt.Println(e.Err)
149+
fmt.Fprintln(os.Stderr, e.Err)
150150
os.Exit(e.Code)
151151
default:
152-
fmt.Println(e)
152+
fmt.Fprintln(os.Stderr, e)
153153
os.Exit(failureExitCode)
154154
}
155155
}

internal/commands/root.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ func NewAstCLI(
242242
)
243243

244244
rootCmd.SilenceUsage = true
245+
// Avoid Cobra printing the error in addition to our own handling in main
246+
rootCmd.SilenceErrors = true
245247
return rootCmd
246248
}
247249

0 commit comments

Comments
 (0)