Skip to content

Commit

Permalink
refactor: improve logging for unimplemented ErrorTranslator in Transl…
Browse files Browse the repository at this point in the history
…ateError config (#7225)
  • Loading branch information
Invidam authored Oct 9, 2024
1 parent 62bd0b9 commit 8020e8c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gorm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8020e8c

Please sign in to comment.