(error: unknown)
| 222 | * @returns The HTTP status code, or undefined if not found. |
| 223 | */ |
| 224 | export function getErrorStatus(error: unknown): number | undefined { |
| 225 | if (typeof error === 'object' && error !== null) { |
| 226 | if ('status' in error && typeof error.status === 'number') { |
| 227 | return error.status; |
| 228 | } |
| 229 | // Check for error.response.status (common in axios errors) |
| 230 | if ( |
| 231 | 'response' in error && |
| 232 | typeof (error as { response?: unknown }).response === 'object' && |
| 233 | (error as { response?: unknown }).response !== null |
| 234 | ) { |
| 235 | const response = ( |
| 236 | error as { response: { status?: unknown; headers?: unknown } } |
| 237 | ).response; |
| 238 | if ('status' in response && typeof response.status === 'number') { |
| 239 | return response.status; |
| 240 | } |
| 241 | } |
| 242 | } |
| 243 | return undefined; |
| 244 | } |
| 245 | |
| 246 | /** |
| 247 | * Extracts the Retry-After delay from an error object's headers. |
no outgoing calls
no test coverage detected