Refactor error handling in isRateLimitError function for improved clarity

This commit is contained in:
priyagupta108 2026-07-09 09:40:20 +05:30
parent 9737be46d4
commit 0bc3767d34
3 changed files with 8 additions and 12 deletions

View file

@ -151,9 +151,11 @@ function sleep(ms: number): Promise<void> {
// HTTP 403/429 from http-client (`statusCode`) or tool-cache (`httpStatusCode`).
function isRateLimitError(err: unknown): boolean {
const status =
(err as {httpStatusCode?: number}).httpStatusCode ??
(err as {statusCode?: number}).statusCode;
const e = err as
| {httpStatusCode?: number; statusCode?: number}
| null
| undefined;
const status = e?.httpStatusCode ?? e?.statusCode;
return status === 403 || status === 429;
}