SmartSql icon indicating copy to clipboard operation
SmartSql copied to clipboard

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

Open lindexi opened this issue 5 years ago • 5 comments

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)

图片

lindexi avatar Dec 01 '20 01:12 lindexi

提供一下复现步骤

Ahoo-Wang avatar Dec 01 '20 05:12 Ahoo-Wang

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

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

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

lindexi avatar Dec 01 '20 10:12 lindexi

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

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)

Ahoo-Wang avatar Dec 01 '20 12:12 Ahoo-Wang

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

多谢大佬

lindexi avatar Dec 01 '20 12:12 lindexi

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

Ahoo-Wang avatar Dec 01 '20 12:12 Ahoo-Wang