r"""Handles the HTTP errors based on the status code of the response. Args: response (requests.Response): The HTTP response from the API call. Returns: str: The error type, based on the status code.
(response: requests.Response)
| 600 | |
| 601 | |
| 602 | def handle_http_error(response: requests.Response) -> str: |
| 603 | r"""Handles the HTTP errors based on the status code of the response. |
| 604 | |
| 605 | Args: |
| 606 | response (requests.Response): The HTTP response from the API call. |
| 607 | |
| 608 | Returns: |
| 609 | str: The error type, based on the status code. |
| 610 | """ |
| 611 | if response.status_code == HTTPStatus.UNAUTHORIZED: |
| 612 | return "Unauthorized. Check your access token." |
| 613 | elif response.status_code == HTTPStatus.FORBIDDEN: |
| 614 | return "Forbidden. You do not have permission to perform this action." |
| 615 | elif response.status_code == HTTPStatus.NOT_FOUND: |
| 616 | return "Not Found. The resource could not be located." |
| 617 | elif response.status_code == HTTPStatus.TOO_MANY_REQUESTS: |
| 618 | return "Too Many Requests. You have hit the rate limit." |
| 619 | else: |
| 620 | return "HTTP Error" |
| 621 | |
| 622 | |
| 623 | def retry_request( |