Skip to content

Commit 7fb832a

Browse files
authored
List databases: Add 40532 as known login failure error code. Allows operation to continue after failing to connect to master. (#2457)
1 parent 6333fc2 commit 7fb832a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Microsoft.SqlTools.ServiceLayer/Connection/ListDatabaseRequestHandler.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ public ListDatabasesResponse HandleRequest(ISqlConnectionFactory connectionFacto
8686
{
8787
// Retry when login attempt failed.
8888
// https://learn.microsoft.com/sql/relational-databases/errors-events/mssqlserver-18456-database-engine-error
89-
if (i != databasesToTry.Count - 1 && ex.Number == 18456)
89+
// 40532: Cannot open server "%.*ls" requested by the login. The login failed.
90+
// https://learn.microsoft.com/sql/relational-databases/errors-events/database-engine-events-and-errors-31000-to-41399
91+
if (i != databasesToTry.Count - 1 && (ex.Number == 18456 || ex.Number == 40532))
9092
{
9193
Logger.Information(string.Format("Failed to get database list from database '{0}', will fallback to original database.", databasesToTry[i]));
9294
continue;

0 commit comments

Comments
 (0)