浏览代码

修改报错格式

yjp 4 月之前
父节点
当前提交
f373732ee7
共有 1 个文件被更改,包括 7 次插入7 次删除
  1. 7 7
      framework/core/domain/object.go

+ 7 - 7
framework/core/domain/object.go

@@ -101,7 +101,7 @@ func CheckFieldsForUpdate(object Object, fieldMap map[string]string) error {
 func Check(object Object, fieldMap map[string]string) error {
 	err := check.Struct(object, fieldMap).CheckWhen("")
 	if err != nil {
-		return errors.New(object.DomainCNName() + ":\n" + err.Error())
+		return errors.New(object.DomainCNName() + ": " + err.Error())
 	}
 
 	return nil
@@ -123,7 +123,7 @@ func CheckField(object Object, fieldName string, fieldMap map[string]string) err
 		return false
 	})
 	if err != nil {
-		return errors.New(object.DomainCNName() + ":\n" + err.Error())
+		return errors.New(object.DomainCNName() + ": " + err.Error())
 	}
 
 	return nil
@@ -139,7 +139,7 @@ func CheckField(object Object, fieldName string, fieldMap map[string]string) err
 func CheckFields(object Object, fieldMap map[string]string, checkFunc func(fieldName string) bool) error {
 	err := check.Struct(object, fieldMap).CheckFieldWhen("", checkFunc)
 	if err != nil {
-		return errors.New(object.DomainCNName() + ":\n" + err.Error())
+		return errors.New(object.DomainCNName() + ": " + err.Error())
 	}
 
 	return nil
@@ -155,7 +155,7 @@ func CheckFields(object Object, fieldMap map[string]string, checkFunc func(field
 func CheckWhen(object Object, fieldMap map[string]string, when string) error {
 	err := check.Struct(object, fieldMap).CheckWhen(when)
 	if err != nil {
-		return errors.New(object.DomainCNName() + ":\n" + err.Error())
+		return errors.New(object.DomainCNName() + ": " + err.Error())
 	}
 
 	return nil
@@ -170,8 +170,8 @@ func CheckWhen(object Object, fieldMap map[string]string, when string) error {
 // 返回值:
 // - 错误
 func CheckFieldWhen(object Object, fieldName string, fieldMap map[string]string, when string) error {
-	err := check.Struct(object, fieldMap).CheckFieldWhen(when, func(fieldName string) bool {
-		if fieldName == fieldName {
+	err := check.Struct(object, fieldMap).CheckFieldWhen(when, func(fn string) bool {
+		if fieldName == fn {
 			return true
 		}
 
@@ -195,7 +195,7 @@ func CheckFieldWhen(object Object, fieldName string, fieldMap map[string]string,
 func CheckFieldsWhen(object Object, fieldMap map[string]string, when string, checkFunc func(fieldName string) bool) error {
 	err := check.Struct(object, fieldMap).CheckFieldWhen(when, checkFunc)
 	if err != nil {
-		return errors.New(object.DomainCNName() + ":\n" + err.Error())
+		return errors.New(object.DomainCNName() + ": " + err.Error())
 	}
 
 	return nil