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

31 lines
417 B

3 years ago
/*
* @desc:错误处理
*
*
* @Date: 2022/3/2 14:53
*/
package liberr
import (
"context"
"github.com/gogf/gf/v2/frame/g"
)
func ErrIsNil(ctx context.Context, err error, msg ...string) {
if !g.IsNil(err) {
if len(msg) > 0 {
g.Log().Error(ctx, err.Error())
panic(msg[0])
} else {
panic(err.Error())
}
}
}
func ValueIsNil(value interface{}, msg string) {
if g.IsNil(value) {
panic(msg)
}
}