diff --git a/core/nstatus/check.go b/core/nstatus/check.go new file mode 100644 index 0000000..5a5ef30 --- /dev/null +++ b/core/nstatus/check.go @@ -0,0 +1,24 @@ +package nstatus + +import ( + "git.noahlan.cn/noahlan/ntool-biz/core/nstatus/code" + "git.noahlan.cn/noahlan/ntool-biz/core/nstatus/msg" +) + +// IsNotFound 判断错误是否属于NotFound +func IsNotFound(err error) bool { + nErr := ConvertErr(err) + if nErr == nil { + return false + } + return nErr.Code == code.StatusNotFound +} + +// IsDatabaseErr 判断错误是否属于数据库错误 +func IsDatabaseErr(err error) bool { + nErr := ConvertErr(err) + if nErr == nil { + return false + } + return nErr.Msg == msg.DatabaseError +}