MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / handle_http_error

Function handle_http_error

camel/utils/commons.py:602–620  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

600
601
602def 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
623def retry_request(

Callers 1

delete_postMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected