(
cls,
*,
http_resp,
body: Optional[str],
data: Optional[Any],
)
| 103 | |
| 104 | @classmethod |
| 105 | def from_response( |
| 106 | cls, |
| 107 | *, |
| 108 | http_resp, |
| 109 | body: Optional[str], |
| 110 | data: Optional[Any], |
| 111 | ) -> Self: |
| 112 | if http_resp.status == 400: |
| 113 | raise BadRequestException(http_resp=http_resp, body=body, data=data) |
| 114 | |
| 115 | if http_resp.status == 401: |
| 116 | raise UnauthorizedException(http_resp=http_resp, body=body, data=data) |
| 117 | |
| 118 | if http_resp.status == 403: |
| 119 | raise ForbiddenException(http_resp=http_resp, body=body, data=data) |
| 120 | |
| 121 | if http_resp.status == 404: |
| 122 | raise NotFoundException(http_resp=http_resp, body=body, data=data) |
| 123 | |
| 124 | if 500 <= http_resp.status <= 599: |
| 125 | raise ServiceException(http_resp=http_resp, body=body, data=data) |
| 126 | raise ApiException(http_resp=http_resp, body=body, data=data) |
| 127 | |
| 128 | def __str__(self): |
| 129 | """Custom error messages for exception""" |
no test coverage detected