Source File
error_translator.go
Belonging Package
gorm.io/driver/mysql
package mysql
import (
)
// The error codes to map mysql errors to gorm errors, here is the mysql error codes reference https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference.html.
var errCodes = map[uint16]error{
1062: gorm.ErrDuplicatedKey,
1452: gorm.ErrForeignKeyViolated,
}
func ( Dialector) ( error) error {
if , := .(*mysql.MySQLError); {
if , := errCodes[.Number]; {
return
}
return
}
return
}
![]() |
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |