1from http import HTTPStatus 2 3from fishjam._openapi_client.models import Error 4from fishjam._openapi_client.types import Response 5 6 7class MissingFishjamIdError(ValueError): 8 def __init__(self) -> None: 9 super().__init__("Fishjam ID is required") 10 11 12class HTTPError(Exception): 13 """""" 14 15 @staticmethod 16 def from_response(response: Response[Error]): 17 """@private""" 18 if not response.parsed: 19 raise RuntimeError("Got endpoint error reponse without parsed field") 20 21 errors = response.parsed.errors 22 23 match response.status_code: 24 case HTTPStatus.BAD_REQUEST: 25 return BadRequestError(errors) 26 27 case HTTPStatus.UNAUTHORIZED: 28 return UnauthorizedError(errors) 29 30 case HTTPStatus.NOT_FOUND: 31 return NotFoundError(errors) 32 33 case HTTPStatus.SERVICE_UNAVAILABLE: 34 return ServiceUnavailableError(errors) 35 36 case HTTPStatus.CONFLICT: 37 return ConflictError(errors) 38 39 case _: 40 return InternalServerError(errors) 41 42 43class BadRequestError(HTTPError): 44 def __init__(self, errors): 45 """@private""" 46 super().__init__(errors) 47 48 49class UnauthorizedError(HTTPError): 50 def __init__(self, errors): 51 """@private""" 52 super().__init__(errors) 53 54 55class NotFoundError(HTTPError): 56 def __init__(self, errors): 57 """@private""" 58 super().__init__(errors) 59 60 61class ServiceUnavailableError(HTTPError): 62 def __init__(self, errors): 63 """@private""" 64 super().__init__(errors) 65 66 67class InternalServerError(HTTPError): 68 def __init__(self, errors): 69 """@private""" 70 super().__init__(errors) 71 72 73class ConflictError(HTTPError): 74 def __init__(self, errors): 75 """@private""" 76 super().__init__(errors) 77 78 79class InvalidFishjamCredentialsError(HTTPError): 80 def __init__(self, errors): 81 """@private""" 82 super().__init__(errors)
class
MissingFishjamIdError(builtins.ValueError):
8class MissingFishjamIdError(ValueError): 9 def __init__(self) -> None: 10 super().__init__("Fishjam ID is required")
Inappropriate argument value (of correct type).
Inherited Members
- builtins.BaseException
- with_traceback
- add_note
- args
class
HTTPError(builtins.Exception):
13class HTTPError(Exception): 14 """""" 15 16 @staticmethod 17 def from_response(response: Response[Error]): 18 """@private""" 19 if not response.parsed: 20 raise RuntimeError("Got endpoint error reponse without parsed field") 21 22 errors = response.parsed.errors 23 24 match response.status_code: 25 case HTTPStatus.BAD_REQUEST: 26 return BadRequestError(errors) 27 28 case HTTPStatus.UNAUTHORIZED: 29 return UnauthorizedError(errors) 30 31 case HTTPStatus.NOT_FOUND: 32 return NotFoundError(errors) 33 34 case HTTPStatus.SERVICE_UNAVAILABLE: 35 return ServiceUnavailableError(errors) 36 37 case HTTPStatus.CONFLICT: 38 return ConflictError(errors) 39 40 case _: 41 return InternalServerError(errors)
Inherited Members
- builtins.BaseException
- BaseException
- with_traceback
- add_note
- args
44class BadRequestError(HTTPError): 45 def __init__(self, errors): 46 """@private""" 47 super().__init__(errors)
Inherited Members
- builtins.BaseException
- with_traceback
- add_note
- args
56class NotFoundError(HTTPError): 57 def __init__(self, errors): 58 """@private""" 59 super().__init__(errors)
Inherited Members
- builtins.BaseException
- with_traceback
- add_note
- args
68class InternalServerError(HTTPError): 69 def __init__(self, errors): 70 """@private""" 71 super().__init__(errors)
Inherited Members
- builtins.BaseException
- with_traceback
- add_note
- args
74class ConflictError(HTTPError): 75 def __init__(self, errors): 76 """@private""" 77 super().__init__(errors)
Inherited Members
- builtins.BaseException
- with_traceback
- add_note
- args
80class InvalidFishjamCredentialsError(HTTPError): 81 def __init__(self, errors): 82 """@private""" 83 super().__init__(errors)
Inherited Members
- builtins.BaseException
- with_traceback
- add_note
- args