Simplify Error handling in Code Assist onboarding (#1123)

This commit is contained in:
Tommaso Sciortino 2025-06-16 18:30:55 -07:00 committed by GitHub
parent a7e45d47cd
commit 98093e604a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 12 deletions

View File

@ -7,7 +7,6 @@
import { ClientMetadata, OnboardUserRequest } from './types.js';
import { CodeAssistServer } from './server.js';
import { OAuth2Client } from 'google-auth-library';
import { GaxiosError } from 'gaxios';
import { clearCachedCredentials } from './oauth2.js';
/**
@ -53,17 +52,12 @@ export async function setupUser(
return lroRes.response?.cloudaicompanionProject?.id || '';
} catch (e) {
if (e instanceof GaxiosError) {
const detail = e.response?.data?.error?.details[0].detail;
if (detail && detail.includes('projectID is empty')) {
await clearCachedCredentials();
console.log(
'\n\nEnterprise users must specify GOOGLE_CLOUD_PROJECT ' +
'in your environment variables or .env file.\n\n',
'\n\nError onboarding with Code Assist.\n' +
'Enterprise users must specify GOOGLE_CLOUD_PROJECT ' +
'in their environment variables or .env file.\n\n',
);
process.exit(1);
}
}
throw e;
}
}