Flatten connection login error handling

This commit is contained in:
Asier Isayas
2026-08-28 14:09:02 -07:00
parent 237391734c
commit b202bf9b7c
@@ -57,19 +57,21 @@ export const ConnectExplorer: React.FunctionComponent<Props> = ({
setIsBlockedByFirewall(false); setIsBlockedByFirewall(false);
setIsConnecting(true); setIsConnecting(true);
try {
try { try {
if (await isAccountRestrictedForConnectionStringLogin(connectionString)) { if (await isAccountRestrictedForConnectionStringLogin(connectionString)) {
setErrorMessage( setErrorMessage(
"This account has been blocked from connection-string login. Please go to cosmos.azure.com/aad for AAD based login.", "This account has been blocked from connection-string login. Please go to cosmos.azure.com/aad for AAD based login.",
); );
setIsConnecting(false);
return; return;
} }
} catch (error) { } catch (error) {
setErrorMessage(getErrorMessage(error as Error)); setErrorMessage(getErrorMessage(error as Error));
setIsConnecting(false);
return; return;
} }
try {
if (isResourceTokenConnectionString(connectionString)) { if (isResourceTokenConnectionString(connectionString)) {
setAuthType(AuthType.ResourceToken); setAuthType(AuthType.ResourceToken);
return; return;
@@ -90,7 +92,6 @@ export const ConnectExplorer: React.FunctionComponent<Props> = ({
} }
// Mongo and Cassandra go through the Portal Backend // Mongo and Cassandra go through the Portal Backend
try {
const encryptedToken = await fetchEncryptedToken(connectionString); const encryptedToken = await fetchEncryptedToken(connectionString);
setEncryptedToken(encryptedToken); setEncryptedToken(encryptedToken);
setAuthType(AuthType.ConnectionString); setAuthType(AuthType.ConnectionString);
@@ -106,7 +107,6 @@ export const ConnectExplorer: React.FunctionComponent<Props> = ({
// string is exchanged by the Portal Backend rather than the browser, so the account has // string is exchanged by the Portal Backend rather than the browser, so the account has
// to allowlist those services. // to allowlist those services.
setIsBlockedByFirewall((error as Response).status === HttpStatusCodes.Forbidden); setIsBlockedByFirewall((error as Response).status === HttpStatusCodes.Forbidden);
}
} finally { } finally {
setIsConnecting(false); setIsConnecting(false);
} }