From 053a625cb553d6feea349f7afbcf05b935f482b8 Mon Sep 17 00:00:00 2001 From: NoahLan <6995syu@163.com> Date: Tue, 19 Sep 2023 14:32:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20nstatus=E6=96=B0=E5=A2=9E=E5=BF=AB?= =?UTF-8?q?=E9=80=9F=E6=A3=80=E6=9F=A5=E6=96=B9=E6=B3=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/nstatus/check.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 core/nstatus/check.go 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 +}