gebn/bmc

Use non-zero exit codes for failures in cmd/describe/

lukeyeager opened this issue · 1 comments

It would be nice to use log.Fatal() here (and in the 3 other spots in that function which are treated as irrecoverable errors):

bmc/cmd/describe/main.go

Lines 81 to 82 in 30abb01

log.Print(err)
return

When testing new versions, I like to loop through my BMCs to see whether this library can connect to them w/o errors (FYI, as of #51 (comment), they all work! 🎉). I'll work on getting approval for sending PRs in the future.

gebn commented

log.Fatal() is suboptimal as it ignores deferred logic. I agree with your point though. The nicest way I can think of is to create a wrapper function:

func main() {
	if err := realMain(context.Background()); err != nil {
		log.Fatal(err)
	}
}

func realMain(ctx context.Context) error {
	// current main() here, deferring clean-up logic and returning fatal errors
}