12345678910111213141516171819202122 |
- package dto
- import (
- "errors"
- "github.com/go-sql-driver/mysql"
- )
- var (
- GetFailedErr = errors.New("查询失败")
- CreateFailedErr = errors.New("添加失败")
- UpdateFailedErr = errors.New("更新失败")
- DeleteFailedErr = errors.New("删除失败")
- GetNotFoundErr = errors.New("数据不存在")
- )
- func IsUniqueIndexErr(err error) bool {
- uniqueErr := &mysql.MySQLError{}
- if ok := errors.As(err, &uniqueErr); ok {
- return uniqueErr.Number == 1062
- }
- return false
- }
|