Files
pterodactyl-panel/resources/scripts/api/queryRetry.ts
T
6c0413e39b Start 2.0 development
Co-authored-by: Anthony <anthony@infraly.co>
Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
2026-10-05 18:10:18 -04:00

13 lines
436 B
TypeScript

import { isAxiosError } from 'axios';
export const isClientErrorResponse = (error: Error): boolean => {
const status = isAxiosError(error) ? error.response?.status : undefined;
return status !== undefined && status >= 400 && status < 500;
};
export const retryUnlessClientError =
(maxRetries = 1) =>
(failureCount: number, error: Error): boolean =>
failureCount < maxRetries && !isClientErrorResponse(error);