mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-20 19:11:23 -07:00
fix(cli): resolve environment loading and auth validation issues in ACP mode (#18025)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
@@ -15,11 +15,41 @@ export function isNodeError(error: unknown): error is NodeJS.ErrnoException {
|
||||
}
|
||||
|
||||
export function getErrorMessage(error: unknown): string {
|
||||
if (error instanceof Error) {
|
||||
return error.message;
|
||||
const friendlyError = toFriendlyError(error);
|
||||
return extractMessage(friendlyError);
|
||||
}
|
||||
|
||||
function extractMessage(input: unknown): string {
|
||||
if (input instanceof Error) {
|
||||
return extractMessage(input.message);
|
||||
}
|
||||
|
||||
if (typeof input === 'string') {
|
||||
const trimmed = input.trim();
|
||||
// Attempt to parse JSON error responses (common in Google API errors)
|
||||
if (
|
||||
(trimmed.startsWith('{') && trimmed.endsWith('}')) ||
|
||||
(trimmed.startsWith('[') && trimmed.endsWith(']'))
|
||||
) {
|
||||
try {
|
||||
const parsed = JSON.parse(trimmed);
|
||||
const next =
|
||||
parsed?.error?.message ||
|
||||
parsed?.[0]?.error?.message ||
|
||||
parsed?.message;
|
||||
|
||||
if (next && next !== input) {
|
||||
return extractMessage(next);
|
||||
}
|
||||
} catch {
|
||||
// Fall back to original string if parsing fails
|
||||
}
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
try {
|
||||
return String(error);
|
||||
return String(input);
|
||||
} catch {
|
||||
return 'Failed to get error details';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user