Skip to content

ReductError

Bases: Exception

General exception for all HTTP errors

Source code in reduct/error.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
28
29
30
31
class ReductError(Exception):
    """General exception for all HTTP errors"""

    def __init__(self, code: int, message: str):
        self._code = code
        self._message = message
        super().__init__(f"Status {self._code}: {self.message}")

    @staticmethod
    def from_header(header: str) -> "ReductError":
        """Create ReductError from HTTP header
        with status code and message (batched write
        )"""
        status_code, message = header.split(",", 1)
        return ReductError(int(status_code), message)

    @property
    def status_code(self):
        """Return HTTP status code"""
        return self._code

    @property
    def message(self):
        """Return error message"""
        return self._message

    def __eq__(self, other: "ReductError"):
        return self._code == other._code and self._message == other._message

message property

Return error message

status_code property

Return HTTP status code

from_header(header) staticmethod

Create ReductError from HTTP header with status code and message (batched write )

Source code in reduct/error.py
12
13
14
15
16
17
18
@staticmethod
def from_header(header: str) -> "ReductError":
    """Create ReductError from HTTP header
    with status code and message (batched write
    )"""
    status_code, message = header.split(",", 1)
    return ReductError(int(status_code), message)