Parcourir la source

新增常用两个codes

dcsunny il y a 4 ans
Parent
commit
9a03130093
1 fichiers modifiés avec 10 ajouts et 1 suppressions
  1. 10 1
      codes/code.go

+ 10 - 1
codes/code.go

@@ -2,10 +2,19 @@ package codes
 
 import "github.com/go-kratos/kratos/v2/errors"
 
-func SystemErr() error {
+func Error(code int32, msg string) error {
+	return errors.Error(code, "", msg)
+}
+
+func CommonErr(msg string) error {
+	return errors.Error(10400, "", msg)
+}
+
+func SystemErr(msg string) error {
 	return errors.Error(10500, "", "")
 }
 
+// 自定义返回值. 如自字重定向
 func Customize() error {
 	return errors.Error(-1, "", "")
 }