mirror of
https://github.com/pterodactyl/panel.git
synced 2026-11-30 11:25:52 -05:00
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);
|