1from http import HTTPStatus 2 3from jellyfish._openapi_client.types import Response 4 5 6class HTTPError(Exception): 7 """""" 8 9 @staticmethod 10 def from_response(response: Response): 11 """@private""" 12 errors = response.parsed.errors 13 if response.status_code == HTTPStatus.BAD_REQUEST: 14 return BadRequestError(errors) 15 16 if response.status_code == HTTPStatus.UNAUTHORIZED: 17 return UnauthorizedError(errors) 18 19 if response.status_code == HTTPStatus.NOT_FOUND: 20 return NotFoundError(errors) 21 22 if response.status_code == HTTPStatus.SERVICE_UNAVAILABLE: 23 return ServiceUnavailableError(errors) 24 25 26class BadRequestError(HTTPError): 27 def __init__(self, errors): 28 """@private""" 29 super().__init__(errors) 30 31 32class UnauthorizedError(HTTPError): 33 def __init__(self, errors): 34 """@private""" 35 super().__init__(errors) 36 37 38class NotFoundError(HTTPError): 39 def __init__(self, errors): 40 """@private""" 41 super().__init__(errors) 42 43 44class ServiceUnavailableError(HTTPError): 45 def __init__(self, errors): 46 """@private""" 47 super().__init__(errors)
class
HTTPError(builtins.Exception):
7class HTTPError(Exception): 8 """""" 9 10 @staticmethod 11 def from_response(response: Response): 12 """@private""" 13 errors = response.parsed.errors 14 if response.status_code == HTTPStatus.BAD_REQUEST: 15 return BadRequestError(errors) 16 17 if response.status_code == HTTPStatus.UNAUTHORIZED: 18 return UnauthorizedError(errors) 19 20 if response.status_code == HTTPStatus.NOT_FOUND: 21 return NotFoundError(errors) 22 23 if response.status_code == HTTPStatus.SERVICE_UNAVAILABLE: 24 return ServiceUnavailableError(errors)
Inherited Members
- builtins.Exception
- Exception
- builtins.BaseException
- with_traceback
- args
27class BadRequestError(HTTPError): 28 def __init__(self, errors): 29 """@private""" 30 super().__init__(errors)
Inherited Members
- builtins.BaseException
- with_traceback
- args
39class NotFoundError(HTTPError): 40 def __init__(self, errors): 41 """@private""" 42 super().__init__(errors)
Inherited Members
- builtins.BaseException
- with_traceback
- args