mirror of
https://github.com/actions/setup-python.git
synced 2026-07-18 23:00:01 +08:00
Refactor error handling in isRateLimitError function for improved clarity
This commit is contained in:
parent
9737be46d4
commit
0bc3767d34
3 changed files with 8 additions and 12 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue