1
This commit is contained in:
19
business/dao/dao_err.go
Normal file
19
business/dao/dao_err.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/client/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
|
||||
}
|
||||
Reference in New Issue
Block a user