diff --git a/lib/http.util.ts b/lib/http.util.ts new file mode 100644 index 0000000..77b0cf8 --- /dev/null +++ b/lib/http.util.ts @@ -0,0 +1,10 @@ +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; +} + +export function isNetworkOrIdempotentRequestOrGatewayError(error: AxiosError): boolean { + return isNetworkOrIdempotentRequestError(error) || isGatewayError(error); +}