Skip to content

Commit 7cd7bdb

Browse files
Merge pull request #1319 from Checkmarx/bug/double-error-log
Fix for double logs and errors (AST-106126)
2 parents 6408e9e + 4b8b811 commit 7cd7bdb

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)