Skip to content

exceptions

pixel_client.exceptions

PixelBadRequestError

Bases: Exception

Exception raised when a bad request is made to the Pixel API.

Source code in src/pixel_client/exceptions.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class PixelBadRequestError(Exception):
    """Exception raised when a bad request is made to the Pixel API."""

    def __init__(
        self,
        response_json: dict,
        status_code: int,
        method: str,
        url: str,
        request_id: str | None = None,
        body: str | None = None,
    ):
        # Pretty print the response json
        self.json_resp_msg = json.dumps(response_json, indent=4)
        self.status_code = status_code
        self.method = method
        self.url = url
        self.body = body
        self.message = f"Bad request {self.status_code} for {self.method} {self.url} (request ID: {request_id})"
        if body:
            self.message += f"\nPayload:\n{self.body}"
        self.message += f"\nResponse: \n{self.json_resp_msg}"
        # Catch validation errors from pydantic
        super().__init__(self.message)

json_resp_msg instance-attribute

json_resp_msg = json.dumps(response_json, indent=4)

status_code instance-attribute

status_code = status_code

method instance-attribute

method = method

url instance-attribute

url = url

body instance-attribute

body = body

message instance-attribute

message = f"Bad request {self.status_code} for {self.method} {self.url} (request ID: {request_id})"

__init__

__init__(
    response_json: dict,
    status_code: int,
    method: str,
    url: str,
    request_id: str | None = None,
    body: str | None = None,
)
Source code in src/pixel_client/exceptions.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def __init__(
    self,
    response_json: dict,
    status_code: int,
    method: str,
    url: str,
    request_id: str | None = None,
    body: str | None = None,
):
    # Pretty print the response json
    self.json_resp_msg = json.dumps(response_json, indent=4)
    self.status_code = status_code
    self.method = method
    self.url = url
    self.body = body
    self.message = f"Bad request {self.status_code} for {self.method} {self.url} (request ID: {request_id})"
    if body:
        self.message += f"\nPayload:\n{self.body}"
    self.message += f"\nResponse: \n{self.json_resp_msg}"
    # Catch validation errors from pydantic
    super().__init__(self.message)

PixelUploadJobError

Bases: Exception

Exception raised when an upload job fails.

Source code in src/pixel_client/exceptions.py
30
31
32
33
34
35
36
37
38
39
40
41
42
class PixelUploadJobError(Exception):
    """
    Exception raised when an upload job fails.
    """

    def __init__(self, job_id: int, status: str, detail: str):
        self.job_id = job_id
        self.detail = detail
        self.status = status
        message = (
            f"Upload job {job_id} failed with status '{status}', detail: \n{detail}"
        )
        super().__init__(message)

job_id instance-attribute

job_id = job_id

detail instance-attribute

detail = detail

status instance-attribute

status = status

__init__

__init__(job_id: int, status: str, detail: str)
Source code in src/pixel_client/exceptions.py
35
36
37
38
39
40
41
42
def __init__(self, job_id: int, status: str, detail: str):
    self.job_id = job_id
    self.detail = detail
    self.status = status
    message = (
        f"Upload job {job_id} failed with status '{status}', detail: \n{detail}"
    )
    super().__init__(message)

PixelMultipleUploadJobError

Bases: Exception

Exception raised when multiple upload jobs fail.

Source code in src/pixel_client/exceptions.py
45
46
47
48
49
50
51
52
53
54
class PixelMultipleUploadJobError(Exception):
    """
    Exception raised when multiple upload jobs fail.
    """

    def __init__(self, errors: list[PixelUploadJobError]):
        self.errors = errors
        error_messages = "\n".join(str(e) for e in errors)
        message = f"Multiple upload jobs failed:\n{error_messages}"
        super().__init__(message)

errors instance-attribute

errors = errors

__init__

__init__(errors: list[PixelUploadJobError])
Source code in src/pixel_client/exceptions.py
50
51
52
53
54
def __init__(self, errors: list[PixelUploadJobError]):
    self.errors = errors
    error_messages = "\n".join(str(e) for e in errors)
    message = f"Multiple upload jobs failed:\n{error_messages}"
    super().__init__(message)