chore: fix merge conflicts

This commit is contained in:
galz10
2026-02-27 11:13:00 -08:00
parent fb5fbd31f3
commit 86a961fb2b
4 changed files with 28 additions and 16 deletions
+1 -3
View File
@@ -2297,14 +2297,11 @@ Logging in with Google... Restarting Gemini CLI to continue.
} }
setNewAgents(null); setNewAgents(null);
}, },
<<<<<<< HEAD
=======
getPreferredEditor, getPreferredEditor,
clearAccountSuspension: () => { clearAccountSuspension: () => {
setAccountSuspensionInfo(null); setAccountSuspensionInfo(null);
setAuthState(AuthState.Updating); setAuthState(AuthState.Updating);
}, },
>>>>>>> ea48bd941 (feat: better error messages (#20577))
}), }),
[ [
handleThemeSelect, handleThemeSelect,
@@ -2356,6 +2353,7 @@ Logging in with Google... Restarting Gemini CLI to continue.
newAgents, newAgents,
config, config,
historyManager, historyManager,
getPreferredEditor,
], ],
); );
@@ -82,11 +82,8 @@ export interface UIActions {
setAuthContext: (context: { requiresRestart?: boolean }) => void; setAuthContext: (context: { requiresRestart?: boolean }) => void;
handleRestart: () => void; handleRestart: () => void;
handleNewAgentsSelect: (choice: NewAgentsChoice) => Promise<void>; handleNewAgentsSelect: (choice: NewAgentsChoice) => Promise<void>;
<<<<<<< HEAD
=======
getPreferredEditor: () => EditorType | undefined; getPreferredEditor: () => EditorType | undefined;
clearAccountSuspension: () => void; clearAccountSuspension: () => void;
>>>>>>> ea48bd941 (feat: better error messages (#20577))
} }
export const UIActionsContext = createContext<UIActions | null>(null); export const UIActionsContext = createContext<UIActions | null>(null);
+8 -3
View File
@@ -13,6 +13,14 @@ import {
ForbiddenError, ForbiddenError,
AccountSuspendedError, AccountSuspendedError,
getErrorMessage, getErrorMessage,
getErrorType,
FatalAuthenticationError,
FatalCancellationError,
FatalConfigError,
FatalInputError,
FatalSandboxError,
FatalToolExecutionError,
FatalTurnLimitedError,
} from './errors.js'; } from './errors.js';
describe('getErrorMessage', () => { describe('getErrorMessage', () => {
@@ -279,8 +287,6 @@ describe('toFriendlyError', () => {
expect(toFriendlyError(error)).toBe(error); expect(toFriendlyError(error)).toBe(error);
}); });
}); });
<<<<<<< HEAD
=======
describe('getErrorType', () => { describe('getErrorType', () => {
it('should return error name for standard errors', () => { it('should return error name for standard errors', () => {
@@ -325,4 +331,3 @@ describe('getErrorType', () => {
expect(getErrorType(undefined)).toBe('unknown'); expect(getErrorType(undefined)).toBe('unknown');
}); });
}); });
>>>>>>> ea48bd941 (feat: better error messages (#20577))
+19 -7
View File
@@ -12,6 +12,16 @@ interface GaxiosError {
}; };
} }
function isGaxiosError(error: unknown): error is GaxiosError {
return (
typeof error === 'object' &&
error !== null &&
'response' in error &&
typeof (error as { response: unknown }).response === 'object' &&
(error as { response: unknown }).response !== null
);
}
export function isNodeError(error: unknown): error is NodeJS.ErrnoException { export function isNodeError(error: unknown): error is NodeJS.ErrnoException {
return error instanceof Error && 'code' in error; return error instanceof Error && 'code' in error;
} }
@@ -28,6 +38,15 @@ export function getErrorMessage(error: unknown): string {
} }
} }
export function getErrorType(error: unknown): string {
if (!(error instanceof Error)) return 'unknown';
// Return constructor name if the generic 'Error' name is used (for custom errors)
return error.name === 'Error'
? (error.constructor?.name ?? 'Error')
: error.name;
}
export class FatalError extends Error { export class FatalError extends Error {
constructor( constructor(
message: string, message: string,
@@ -110,12 +129,6 @@ interface ResponseData {
} }
export function toFriendlyError(error: unknown): unknown { export function toFriendlyError(error: unknown): unknown {
<<<<<<< HEAD
if (error && typeof error === 'object' && 'response' in error) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
const gaxiosError = error as GaxiosError;
const data = parseResponseData(gaxiosError);
=======
// First, try structured parsing for TOS_VIOLATION detection. // First, try structured parsing for TOS_VIOLATION detection.
const googleApiError = parseGoogleApiError(error); const googleApiError = parseGoogleApiError(error);
if (googleApiError && googleApiError.code === 403) { if (googleApiError && googleApiError.code === 403) {
@@ -136,7 +149,6 @@ export function toFriendlyError(error: unknown): unknown {
// Fall back to basic Gaxios error parsing for other HTTP errors. // Fall back to basic Gaxios error parsing for other HTTP errors.
if (isGaxiosError(error)) { if (isGaxiosError(error)) {
const data = parseResponseData(error); const data = parseResponseData(error);
>>>>>>> ea48bd941 (feat: better error messages (#20577))
if (data && data.error && data.error.message && data.error.code) { if (data && data.error && data.error.message && data.error.code) {
switch (data.error.code) { switch (data.error.code) {
case 400: case 400: