Skip to content

Commit 8020e8c

Browse files
authored
refactor: improve logging for unimplemented ErrorTranslator in TranslateError config (#7225)
1 parent 62bd0b9 commit 8020e8c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

gorm.go

+6
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ func Open(dialector Dialector, opts ...Option) (db *DB, err error) {
189189
_ = db.Close()
190190
}
191191
}
192+
193+
if config.TranslateError {
194+
if _, ok := db.Dialector.(ErrorTranslator); !ok {
195+
config.Logger.Warn(context.Background(), "The TranslateError option is enabled, but the Dialector %s does not implement ErrorTranslator.", db.Dialector.Name())
196+
}
197+
}
192198
}
193199

194200
if config.PrepareStmt {

0 commit comments

Comments
 (0)