(
cls,
*,
http_resp,
body: Optional[str],
data: Optional[Any],
)
| 132 | |
| 133 | @classmethod |
| 134 | def from_response( |
| 135 | cls, |
| 136 | *, |
| 137 | http_resp, |
| 138 | body: Optional[str], |
| 139 | data: Optional[Any], |
| 140 | ) -> Self: |
| 141 | if http_resp.status == 400: |
| 142 | raise BadRequestException(http_resp=http_resp, body=body, data=data) |
| 143 | |
| 144 | if http_resp.status == 401: |
| 145 | raise UnauthorizedException(http_resp=http_resp, body=body, data=data) |
| 146 | |
| 147 | if http_resp.status == 403: |
| 148 | raise ForbiddenException(http_resp=http_resp, body=body, data=data) |
| 149 | |
| 150 | if http_resp.status == 404: |
| 151 | raise NotFoundException(http_resp=http_resp, body=body, data=data) |
| 152 | |
| 153 | # Added new conditions for 409 and 422 |
| 154 | if http_resp.status == 409: |
| 155 | raise ConflictException(http_resp=http_resp, body=body, data=data) |
| 156 | |
| 157 | if http_resp.status == 422: |
| 158 | raise UnprocessableEntityException(http_resp=http_resp, body=body, data=data) |
| 159 | |
| 160 | if 500 <= http_resp.status <= 599: |
| 161 | raise ServiceException(http_resp=http_resp, body=body, data=data) |
| 162 | raise ApiException(http_resp=http_resp, body=body, data=data) |
| 163 | |
| 164 | def __str__(self): |
| 165 | """Custom error messages for exception""" |
no test coverage detected