I have some tests that verify my application behaves properly when there are database issues. I found that on head these tests not only fail but end the test run due to the call to a call to logger.Fatal (
|
logger.Fatal("Could not query Postgres version") |
), which eventually calls
panic in logxi.
It's recommended to avoid exposing panics to consumer of a package and instead return an error so the consumer can choose how to deal with it. https://github.com/golang/go/wiki/PanicAndRecover#usage-in-a-package
On a related note, I noticed there are also some uses of log.Fatalf in sqlx-runner/db.go and sqlx-runner/tx.go. These call os.Exit(1) and should be avoid for similar reasons.
I have some tests that verify my application behaves properly when there are database issues. I found that on head these tests not only fail but end the test run due to the call to a call to
logger.Fatal(dat/sqlx-runner/db.go
Line 51 in 12949df
panicin logxi.It's recommended to avoid exposing panics to consumer of a package and instead return an error so the consumer can choose how to deal with it. https://github.com/golang/go/wiki/PanicAndRecover#usage-in-a-package
On a related note, I noticed there are also some uses of
log.Fatalfinsqlx-runner/db.goandsqlx-runner/tx.go. These call os.Exit(1) and should be avoid for similar reasons.