You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
604 B
Go

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package dbcheck
import (
"errors"
grds "github.com/go-redis/redis/v8"
"gorm.io/gorm"
)
// DbError 是否是要直接返回的db错误 (gorm.ErrRecordNotFound is not a error)
func DbError(err error) error {
//没找到不算一个错误,判断返回结构体未nil来做处理
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil
}
return err
}
// RdError 是否是要直接返回的redis错误 (grds.Nil is not a error)
func RdError(err error) error {
//没找到不算一个错误,判断返回结构体未nil来做处理
if errors.Is(err, grds.Nil) {
return nil
}
return err
}