Skip to content

Commit

Permalink
🐛 Handle file writing errors as fatal errors (#367)
Browse files Browse the repository at this point in the history
Closes #314

---------

Signed-off-by: sarthaksarthak9 <[email protected]>
  • Loading branch information
sarthaksarthak9 authored Oct 11, 2023
1 parent b6195b3 commit 53a7f0f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/analyzer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,11 @@ func main() {
os.Exit(EXIT_ON_ERROR_CODE)
}

os.WriteFile(outputViolations, b, 0644)
err = os.WriteFile(outputViolations, b, 0644)
if err != nil {
log.Error(err, "error writing output file", "file", outputViolations)
os.Exit(1) // Treat the error as a fatal error
}
}

func validateFlags() error {
Expand Down

0 comments on commit 53a7f0f

Please sign in to comment.