mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 04:18:16 +08:00
- 增加 连接字符串错误时的友好提示;
This commit is contained in:
@ -115,6 +115,12 @@ namespace FreeSql.MySql
|
||||
|
||||
if (_pool.IsAvailable)
|
||||
{
|
||||
if (obj.Value == null)
|
||||
{
|
||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
|
||||
{
|
||||
@ -137,6 +143,12 @@ namespace FreeSql.MySql
|
||||
|
||||
if (_pool.IsAvailable)
|
||||
{
|
||||
if (obj.Value == null)
|
||||
{
|
||||
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
|
||||
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
|
||||
{
|
||||
|
Reference in New Issue
Block a user