(error: any)
| 41 | }) |
| 42 | |
| 43 | export function apiCallErrorHandler(error: any) { |
| 44 | if (error.isAxiosError) { |
| 45 | if (error.request.status === 401) { |
| 46 | // Clear token and return to home page after auth token expiry |
| 47 | clearAccessToken() |
| 48 | window.location.href = window.location.pathname |
| 49 | return |
| 50 | } else if (error.request.status >= 500 && error.request.status < 600) { |
| 51 | // Show error page when we get a 5XX that fails retries |
| 52 | window.location.href = `${window.location.pathname}?spotify_error=true` |
| 53 | return |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | throw error |
| 58 | } |
no test coverage detected