- IsDuplicateError

This commit is contained in:
gazebo
2018-11-06 22:12:18 +08:00
parent 255b0c7655
commit 3661ac61da
3 changed files with 36 additions and 25 deletions

View File

@@ -0,0 +1,19 @@
package dao
import (
"github.com/astaxie/beego/orm"
"github.com/go-sql-driver/mysql"
)
func IsDuplicateError(err error) bool {
if mysqlErr, ok := err.(*mysql.MySQLError); ok {
if mysqlErr.Number == 1062 {
return true
}
}
return false
}
func IsNoRowsError(err error) bool {
return err == orm.ErrNoRows
}