2023-12-24 00:31:33 +00:00
|
|
|
import type { AxiosError } from 'axios';
|
|
|
|
import { isNetworkOrIdempotentRequestError } from 'axios-retry';
|
|
|
|
|
|
|
|
export function isGatewayError(error: AxiosError): boolean {
|
|
|
|
return !!error.response && error.response.status >= 502 && error.response.status <= 504;
|
|
|
|
}
|
|
|
|
|
2024-01-22 02:19:12 +00:00
|
|
|
export function isRateLimitError(error: AxiosError): boolean {
|
|
|
|
return !!error.response && error.response.status === 429;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function isNetworkOrIdempotentRequestOrGatewayOrRateLimitError(error: AxiosError): boolean {
|
|
|
|
return (
|
|
|
|
isNetworkOrIdempotentRequestError(error) || isGatewayError(error) || isRateLimitError(error)
|
|
|
|
);
|
2023-12-24 00:31:33 +00:00
|
|
|
}
|