mirror of
https://github.com/pterodactyl/panel.git
synced 2026-11-30 03:17:56 -05:00
Co-authored-by: Anthony <anthony@infraly.co> Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
13 lines
436 B
TypeScript
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);
|