* Extracts HTTP status code from various error types
(error: unknown)
| 11 | * Extracts HTTP status code from various error types |
| 12 | */ |
| 13 | function getStatusCode(error: unknown): number | null { |
| 14 | // Direct status property (common in API SDKs) |
| 15 | if (typeof (error as any)?.status === 'number') { |
| 16 | return (error as any).status; |
| 17 | } |
| 18 | |
| 19 | // Axios-style errors |
| 20 | if (axios.isAxiosError(error)) { |
| 21 | return error.response?.status ?? null; |
| 22 | } |
| 23 | |
| 24 | // Response object with status |
| 25 | if (typeof (error as any)?.response?.status === 'number') { |
| 26 | return (error as any).response.status; |
| 27 | } |
| 28 | |
| 29 | return null; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Extracts retry-after value from error headers (for rate limiting) |
no outgoing calls
no test coverage detected
searching dependent graphs…