chore: update mysql connection error message and logger style

This commit is contained in:
Zhang Minghan 2024-01-14 15:12:46 +08:00
parent 84485eae16
commit fea7442b85
2 changed files with 4 additions and 3 deletions

View File

@ -62,6 +62,7 @@
overflow-y: auto;
touch-action: pan-y;
padding: 0.5rem;
white-space: pre-wrap !important;
}
.console-icon {

View File

@ -29,11 +29,11 @@ func ConnectMySQL() *sql.DB {
viper.GetInt("mysql.port"),
viper.GetString("mysql.db"),
))
if err != nil || db.Ping() != nil {
if pingErr := db.Ping(); err != nil || pingErr != nil {
errMsg := utils.Multi[string](err != nil, utils.GetError(err), utils.GetError(pingErr)) // err.Error() may contain nil pointer
globals.Warn(
fmt.Sprintf("[connection] failed to connect to mysql server: %s (message: %s), will retry in 5 seconds",
viper.GetString("mysql.host"),
utils.GetError(err), // err.Error() may contain nil pointer
viper.GetString("mysql.host"), errMsg,
),
)