Improve LoadCodeAssist error handling (#1645)

This commit is contained in:
Tommaso Sciortino
2025-06-26 08:27:20 -07:00
committed by GitHub
parent 24ccc9c457
commit c55b15f705
4 changed files with 61 additions and 60 deletions

View File

@@ -141,12 +141,16 @@ export async function main() {
if (sandboxConfig) {
if (settings.merged.selectedAuthType) {
// Validate authentication here because the sandbox will interfere with the Oauth2 web redirect.
const err = validateAuthMethod(settings.merged.selectedAuthType);
if (err) {
console.error(err);
try {
const err = validateAuthMethod(settings.merged.selectedAuthType);
if (err) {
throw new Error(err);
}
await config.refreshAuth(settings.merged.selectedAuthType);
} catch (err) {
console.error('Error authenticating:', err);
process.exit(1);
}
await config.refreshAuth(settings.merged.selectedAuthType);
}
await start_sandbox(sandboxConfig, memoryArgs);
process.exit(0);

View File

@@ -46,17 +46,7 @@ export const useAuthCommand = (
config,
);
} catch (e) {
let errorMessage = `Failed to login.\nMessage: ${getErrorMessage(e)}`;
if (
settings.merged.selectedAuthType ===
AuthType.LOGIN_WITH_GOOGLE_PERSONAL &&
!process.env.GOOGLE_CLOUD_PROJECT
) {
errorMessage =
'Failed to login. Workspace accounts and licensed Code Assist users must configure' +
` GOOGLE_CLOUD_PROJECT (see https://goo.gle/gemini-cli-auth-docs#workspace-gca).\nMessage: ${getErrorMessage(e)}`;
}
setAuthError(errorMessage);
setAuthError(`Failed to login. Message: ${getErrorMessage(e)}`);
openAuthDialog();
} finally {
setIsAuthenticating(false);