fix(core): improve API response error handling and retry logic (#14563)

This commit is contained in:
matt korwel
2025-12-05 09:49:08 -08:00
committed by GitHub
parent 738354ff65
commit dd3fd73ffe
8 changed files with 375 additions and 45 deletions

View File

@@ -22,8 +22,9 @@ export class FetchError extends Error {
constructor(
message: string,
public code?: string,
options?: ErrorOptions,
) {
super(message);
super(message, options);
this.name = 'FetchError';
}
}
@@ -51,7 +52,7 @@ export async function fetchWithTimeout(
if (isNodeError(error) && error.code === 'ABORT_ERR') {
throw new FetchError(`Request timed out after ${timeout}ms`, 'ETIMEDOUT');
}
throw new FetchError(getErrorMessage(error));
throw new FetchError(getErrorMessage(error), undefined, { cause: error });
} finally {
clearTimeout(timeoutId);
}