refactor: improve logging for unimplemented ErrorTranslator in TranslateError config (#7225)

This commit is contained in:
Hansu Park 2024-10-09 20:29:48 +09:00 committed by GitHub
parent 62bd0b9331
commit 8020e8c166
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 0 deletions

View File

@ -189,6 +189,12 @@ func Open(dialector Dialector, opts ...Option) (db *DB, err error) {
_ = db.Close()
}
}
if config.TranslateError {
if _, ok := db.Dialector.(ErrorTranslator); !ok {
config.Logger.Warn(context.Background(), "The TranslateError option is enabled, but the Dialector %s does not implement ErrorTranslator.", db.Dialector.Name())
}
}
}
if config.PrepareStmt {