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
+8 -3
View File
@@ -13,6 +13,14 @@ import {
ForbiddenError,
AccountSuspendedError,
getErrorMessage,
getErrorType,
FatalAuthenticationError,
FatalCancellationError,
FatalConfigError,
FatalInputError,
FatalSandboxError,
FatalToolExecutionError,
FatalTurnLimitedError,
} from './errors.js';
describe('getErrorMessage', () => {
@@ -279,8 +287,6 @@ describe('toFriendlyError', () => {
expect(toFriendlyError(error)).toBe(error);
});
});
<<<<<<< HEAD
=======
describe('getErrorType', () => {
it('should return error name for standard errors', () => {
@@ -325,4 +331,3 @@ describe('getErrorType', () => {
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 {
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 {
constructor(
message: string,
@@ -110,12 +129,6 @@ interface ResponseData {
}
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.
const googleApiError = parseGoogleApiError(error);
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.
if (isGaxiosError(error)) {
const data = parseResponseData(error);
>>>>>>> ea48bd941 (feat: better error messages (#20577))
if (data && data.error && data.error.message && data.error.code) {
switch (data.error.code) {
case 400: