Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

找不到配置项的异常提示有点迷 #147

Open
lindexi opened this issue Dec 1, 2020 · 5 comments
Open

找不到配置项的异常提示有点迷 #147

lindexi opened this issue Dec 1, 2020 · 5 comments
Assignees

Comments

@lindexi
Copy link

lindexi commented Dec 1, 2020

Steps to reproduce

配置进入一个不存在的配置项作为连接字符串

<Database>
    <DbProvider Name="SQLite"/>
    <Write Name="WriteDB" ConnectionString="${SmartSqlConnectionString}"/>
    <Read Name="ReadDb-1" ConnectionString="${SmartSqlConnectionString}" Weight="100"/>
    <Read Name="ReadDb-2" ConnectionString="${SmartSqlConnectionString}" Weight="100"/>
</Database>

如上面代码,没有任何配置添加了 SmartSqlConnectionString 的定义

Expected result

能在异常信息里面体现是配置项缺失,如找不到 xx 配置等

Actual result

    SmartSql.Configuration.Properties.GetPropertyValue.AnonymousMethod__6_0(System.Text.RegularExpressions.Match)
    System.Text.RegularExpressions.Regex.Replace(System.Text.RegularExpressions.MatchEvaluator, System.Text.RegularExpressions.Regex, string, int, int)
    System.Text.RegularExpressions.Regex.Replace(string, System.Text.RegularExpressions.MatchEvaluator)

图片

@Ahoo-Wang
Copy link
Member

提供一下复现步骤

@lindexi
Copy link
Author

lindexi commented Dec 1, 2020

@Ahoo-Wang 最简复现 demo 代码: https://github.com/lindexi/lindexi_gd/tree/176caf10abb0f58a7c8a99bb524e62c20eb17762/LanurleechuHiguburne/KocinarwemNeyejawhere

运行就可以看到了,本质问题就是我的配置文件写错了(没写)出现的异常

但是假设我不知道是我配置文件写错了,只是看异常的内容,不好了解是这个问题

@Ahoo-Wang
Copy link
Member

Ahoo-Wang commented Dec 1, 2020

我这里是有异常提示的。。。

SmartSql.Test.Unit.SmartSqlBuilderTest.Build_By_Xml

SmartSql.Exceptions.SmartSqlException: can not find Property.Name:SmartSqlConnectionString.

SmartSql.Exceptions.SmartSqlException
can not find Property.Name:SmartSqlConnectionString.
   at SmartSql.Configuration.Properties.<GetPropertyValue>b__6_0(Match match)
   at System.Text.RegularExpressions.Regex.Replace(MatchEvaluator evaluator, Regex regex, String input, Int32 count, Int32 startat)
   at System.Text.RegularExpressions.Regex.Replace(String input, MatchEvaluator evaluator, Int32 count, Int32 startat)
   at System.Text.RegularExpressions.Regex.Replace(String input, MatchEvaluator evaluator)
   at SmartSql.Configuration.Properties.GetPropertyValue(String propExp)

@lindexi
Copy link
Author

lindexi commented Dec 1, 2020

@Ahoo-Wang 对的,有异常,但是很难通过异常和堆栈了解到问题所在。换句话说就是异常的文案我期望能更改,让开发者更好的了解到是自己配置的问题

多谢大佬

@Ahoo-Wang
Copy link
Member

你的意思是得提示得更加友好一些,让开发者更快得定位问题对吧。有啥好的建议没有。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants