Skip to content

Commit 5b6cd7e

Browse files
committed
- Added localized string for the new connection timed out exception.
1 parent d33760e commit 5b6cd7e

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniTcpHandle.netcore.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,9 @@ private static Socket Connect(string serverName, int port, TimeoutTimer timeout,
428428
{
429429
if (timeout.IsExpired)
430430
{
431-
throw new Win32Exception(258, "The operation has timed out.");
431+
throw new Win32Exception(
432+
TdsEnums.SNI_WAIT_TIMEOUT,
433+
StringsHelper.GetString(Strings.SQL_ConnectTimeout));
432434
}
433435

434436
int socketSelectTimeout =
@@ -698,7 +700,9 @@ private static Socket ParallelConnect(IPAddress[] serverAddresses, int port, Tim
698700
{
699701
if (timeout.IsExpired)
700702
{
701-
throw new Win32Exception(258, "The operation has timed out.");
703+
throw new Win32Exception(
704+
TdsEnums.SNI_WAIT_TIMEOUT,
705+
StringsHelper.GetString(Strings.SQL_ConnectTimeout));
702706
}
703707

704708
SqlClientEventSource.Log.TryAdvancedTraceEvent(

src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Microsoft.Data.SqlClient/src/Resources/Strings.resx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2520,6 +2520,9 @@
25202520
<data name="SQL_AsyncConnectionRequired" xml:space="preserve">
25212521
<value>This command requires an asynchronous connection. Set "Asynchronous Processing=true" in the connection string.</value>
25222522
</data>
2523+
<data name="SQL_ConnectTimeout" xml:space="preserve">
2524+
<value>The connection attempt timed out.</value>
2525+
</data>
25232526
<data name="SQL_FatalTimeout" xml:space="preserve">
25242527
<value>Timeout expired. The connection has been broken as a result.</value>
25252528
</data>
@@ -4677,4 +4680,4 @@
46774680
<data name="ADP_InvalidJsonStringForVector" xml:space="preserve">
46784681
<value>{0} Invalid JSON string for vector.</value>
46794682
</data>
4680-
</root>
4683+
</root>

0 commit comments

Comments
 (0)