Fishjam Python Server SDK
  1from http import HTTPStatus
  2
  3from fishjam._fishjam_openapi_client.models import Error
  4from fishjam._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 StaleSdkError(Exception):
 13    def __init__(self, status: int) -> None:
 14        super().__init__(
 15            f"Received a recording status this SDK cannot parse ({int(status)})."
 16            " You are probably using an outdated version of fishjam-server-sdk"
 17            " - please update it."
 18        )
 19        self.status = int(status)
 20        """Raw wire value received from the server."""
 21
 22
 23class HTTPError(Exception):
 24    """"""
 25
 26    @staticmethod
 27    def from_response(response: Response[Error]):
 28        """@private"""
 29        if response.parsed:
 30            errors = response.parsed.errors
 31        else:
 32            errors = response.content.decode(errors="replace")
 33
 34        return error_for_status(response.status_code, errors)
 35
 36
 37class BadRequestError(HTTPError):
 38    def __init__(self, errors):
 39        """@private"""
 40        super().__init__(errors)
 41
 42
 43class UnauthorizedError(HTTPError):
 44    def __init__(self, errors):
 45        """@private"""
 46        super().__init__(errors)
 47
 48
 49class NotFoundError(HTTPError):
 50    def __init__(self, errors):
 51        """@private"""
 52        super().__init__(errors)
 53
 54
 55class CompositionNotFoundError(NotFoundError):
 56    def __init__(self, errors):
 57        """@private"""
 58        super().__init__(errors)
 59
 60
 61class InputNotFoundError(NotFoundError):
 62    def __init__(self, errors):
 63        """@private"""
 64        super().__init__(errors)
 65
 66
 67class OutputNotFoundError(NotFoundError):
 68    def __init__(self, errors):
 69        """@private"""
 70        super().__init__(errors)
 71
 72
 73class RendererNotFoundError(NotFoundError):
 74    def __init__(self, errors):
 75        """@private"""
 76        super().__init__(errors)
 77
 78
 79class ServiceUnavailableError(HTTPError):
 80    def __init__(self, errors):
 81        """@private"""
 82        super().__init__(errors)
 83
 84
 85class InternalServerError(HTTPError):
 86    def __init__(self, errors):
 87        """@private"""
 88        super().__init__(errors)
 89
 90
 91class ConflictError(HTTPError):
 92    def __init__(self, errors):
 93        """@private"""
 94        super().__init__(errors)
 95
 96
 97class QuotaExceededError(HTTPError):
 98    def __init__(self, errors):
 99        """@private"""
100        super().__init__(errors)
101
102
103class InvalidFishjamCredentialsError(HTTPError):
104    def __init__(self, errors):
105        """@private"""
106        super().__init__(errors)
107
108
109def error_for_status(
110    status_code: int, detail, not_found: type["HTTPError"] | None = None
111) -> HTTPError:
112    """@private"""
113    match status_code:
114        case HTTPStatus.BAD_REQUEST | HTTPStatus.UNPROCESSABLE_ENTITY:
115            return BadRequestError(detail)
116
117        case HTTPStatus.UNAUTHORIZED:
118            return UnauthorizedError(detail)
119
120        case HTTPStatus.PAYMENT_REQUIRED:
121            return QuotaExceededError(detail)
122
123        case HTTPStatus.NOT_FOUND:
124            return (not_found or NotFoundError)(detail)
125
126        case HTTPStatus.CONFLICT:
127            return ConflictError(detail)
128
129        case HTTPStatus.SERVICE_UNAVAILABLE:
130            return ServiceUnavailableError(detail)
131
132        case _:
133            return InternalServerError(detail)
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 StaleSdkError(builtins.Exception):
13class StaleSdkError(Exception):
14    def __init__(self, status: int) -> None:
15        super().__init__(
16            f"Received a recording status this SDK cannot parse ({int(status)})."
17            " You are probably using an outdated version of fishjam-server-sdk"
18            " - please update it."
19        )
20        self.status = int(status)
21        """Raw wire value received from the server."""

Common base class for all non-exit exceptions.

StaleSdkError(status: int)
14    def __init__(self, status: int) -> None:
15        super().__init__(
16            f"Received a recording status this SDK cannot parse ({int(status)})."
17            " You are probably using an outdated version of fishjam-server-sdk"
18            " - please update it."
19        )
20        self.status = int(status)
21        """Raw wire value received from the server."""
status

Raw wire value received from the server.

Inherited Members
builtins.BaseException
with_traceback
add_note
args
class HTTPError(builtins.Exception):
24class HTTPError(Exception):
25    """"""
26
27    @staticmethod
28    def from_response(response: Response[Error]):
29        """@private"""
30        if response.parsed:
31            errors = response.parsed.errors
32        else:
33            errors = response.content.decode(errors="replace")
34
35        return error_for_status(response.status_code, errors)
Inherited Members
builtins.BaseException
BaseException
with_traceback
add_note
args
class BadRequestError(HTTPError):
38class BadRequestError(HTTPError):
39    def __init__(self, errors):
40        """@private"""
41        super().__init__(errors)
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class UnauthorizedError(HTTPError):
44class UnauthorizedError(HTTPError):
45    def __init__(self, errors):
46        """@private"""
47        super().__init__(errors)
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class NotFoundError(HTTPError):
50class NotFoundError(HTTPError):
51    def __init__(self, errors):
52        """@private"""
53        super().__init__(errors)
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class CompositionNotFoundError(NotFoundError):
56class CompositionNotFoundError(NotFoundError):
57    def __init__(self, errors):
58        """@private"""
59        super().__init__(errors)
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class InputNotFoundError(NotFoundError):
62class InputNotFoundError(NotFoundError):
63    def __init__(self, errors):
64        """@private"""
65        super().__init__(errors)
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class OutputNotFoundError(NotFoundError):
68class OutputNotFoundError(NotFoundError):
69    def __init__(self, errors):
70        """@private"""
71        super().__init__(errors)
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class RendererNotFoundError(NotFoundError):
74class RendererNotFoundError(NotFoundError):
75    def __init__(self, errors):
76        """@private"""
77        super().__init__(errors)
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class ServiceUnavailableError(HTTPError):
80class ServiceUnavailableError(HTTPError):
81    def __init__(self, errors):
82        """@private"""
83        super().__init__(errors)
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class InternalServerError(HTTPError):
86class InternalServerError(HTTPError):
87    def __init__(self, errors):
88        """@private"""
89        super().__init__(errors)
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class ConflictError(HTTPError):
92class ConflictError(HTTPError):
93    def __init__(self, errors):
94        """@private"""
95        super().__init__(errors)
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class QuotaExceededError(HTTPError):
 98class QuotaExceededError(HTTPError):
 99    def __init__(self, errors):
100        """@private"""
101        super().__init__(errors)
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class InvalidFishjamCredentialsError(HTTPError):
104class InvalidFishjamCredentialsError(HTTPError):
105    def __init__(self, errors):
106        """@private"""
107        super().__init__(errors)
Inherited Members
builtins.BaseException
with_traceback
add_note
args