【优化】 对于group属性失误用于type添加错误提示

【优化】对于sep失误写成seq添加错误提示
main
walon 2022-03-27 15:20:20 +08:00
parent c146cf6031
commit 82fbdb513f
3 changed files with 21 additions and 4 deletions

View File

@ -269,7 +269,7 @@ Options:
} }
else else
{ {
s_logger.Error("GenJob fail. err:{err} msg:{msg}", res.ErrCode, res.ErrMsg); s_logger.Error("GenJob fail. msg:{msg}", res.ErrMsg);
if (!string.IsNullOrEmpty(res.StackTrace)) if (!string.IsNullOrEmpty(res.StackTrace))
{ {
s_logger.Debug("StackTrace: {}", res.StackTrace); s_logger.Debug("StackTrace: {}", res.StackTrace);

View File

@ -269,7 +269,7 @@ namespace Luban.Job.Common.Defs
{ {
string containerTypeAndTags = DefUtil.TrimBracePairs(type.Substring(0, sepIndex)); string containerTypeAndTags = DefUtil.TrimBracePairs(type.Substring(0, sepIndex));
var elementTypeAndTags = type.Substring(sepIndex + 1); var elementTypeAndTags = type.Substring(sepIndex + 1);
var (containerType, containerTags) = DefUtil.ParseType(containerTypeAndTags); var (containerType, containerTags) = DefUtil.ParseTypeAndVaildAttrs(containerTypeAndTags);
return CreateContainerType(module, containerType, containerTags, elementTypeAndTags.Trim()); return CreateContainerType(module, containerType, containerTags, elementTypeAndTags.Trim());
} }
else else
@ -283,7 +283,7 @@ namespace Luban.Job.Common.Defs
bool nullable; bool nullable;
// 去掉 rawType 两侧的匹配的 () // 去掉 rawType 两侧的匹配的 ()
rawType = DefUtil.TrimBracePairs(rawType); rawType = DefUtil.TrimBracePairs(rawType);
var (type, tags) = DefUtil.ParseType(rawType); var (type, tags) = DefUtil.ParseTypeAndVaildAttrs(rawType);
if (type.EndsWith('?')) if (type.EndsWith('?'))
{ {

View File

@ -183,6 +183,23 @@ namespace Luban.Job.Common.Utils
} }
} }
public static (string, Dictionary<string, string>) ParseTypeAndVaildAttrs(string s)
{
var (typeStr, attrs) = ParseType(s);
if (attrs.ContainsKey("group"))
{
throw new Exception("group为保留属性,只能用于table或var定义,是否用错? 如在excel中请使用&group=xxx");
}
if (attrs.ContainsKey("seq"))
{
throw new Exception("字段切割应该用'sep',而不是'seq',请检查是否拼写错误");
}
return (typeStr, attrs);
}
public static bool ParseOrientation(string value) public static bool ParseOrientation(string value)
{ {
switch (value.Trim()) switch (value.Trim())