Skip to content

Commit

Permalink
Replace log.Fatalf with log.Exitf to avoid spamming stderr. (#1284)
Browse files Browse the repository at this point in the history
* Replace log.Fatalf with log.Exitf to avoid spamming stderr.

The set of warnings is something that is changing over time. As scripts tend to hardcode these, they get out of date and we hit this unexpected warning code path. There's little benefit of having a stack trace from this issue. Thus, it's more convenient to just print the error itself and nothing else.

* Update warn.go
  • Loading branch information
paulherman authored Aug 27, 2024
1 parent 5a4dddc commit ec2ed9d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion warn/warn.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ func FileWarnings(f *build.File, enabledWarnings []string, formatted *[]byte, mo
} else if fct, ok := RuleWarningMap[warn]; ok {
findings = append(findings, runWarningsFunction(warn, f, ruleWarningWrapper(fct), formatted, mode, fileReader)...)
} else {
log.Fatalf("unexpected warning %q", warn)
log.Printf("unexpected warning %q", warn)
os.Exit(1)
}
}
sort.Slice(findings, func(i, j int) bool { return findings[i].Start.Line < findings[j].Start.Line })
Expand Down

0 comments on commit ec2ed9d

Please sign in to comment.