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