Explorar o código

新增常用两个codes

dcsunny %!s(int64=4) %!d(string=hai) anos
pai
achega
9a03130093
Modificáronse 1 ficheiros con 10 adicións e 1 borrados
  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, "", "")
 }