Skip to content

Exceptions

InvalidFileFormat

Bases: Exception

Exception to raise when the file type is incorrect.

Source code in apple_health_parser/exceptions.py
31
32
33
34
35
36
37
38
39
class InvalidFileFormat(Exception):
    """
    Exception to raise when the file type is incorrect.
    """

    def __init__(self, format: str) -> None:
        super().__init__(
            f"File type is incorrect. Requires .csv, but provided {format}."
        )

InvalidFlag

Bases: Exception

Exception to raise when the flag is incorrect.

Source code in apple_health_parser/exceptions.py
42
43
44
45
46
47
48
class InvalidFlag(Exception):
    """
    Exception to raise when the flag is incorrect.
    """

    def __init__(self, flag: str, flags: list[str]) -> None:
        super().__init__(f"Flag '{flag}' is not valid. Allowed flags: {flags}.")

InvalidHeatmapOperation

Bases: Exception

Exception to raise when the operation is invalid for a heatmap (i.e. when operation is None).

Source code in apple_health_parser/exceptions.py
51
52
53
54
55
56
57
58
59
class InvalidHeatmapOperation(Exception):
    """
    Exception to raise when the operation is invalid for a heatmap (i.e. when operation is `None`).
    """

    def __init__(self) -> None:
        super().__init__(
            f"Heatmaps require an operation. Allowed operations: {OPERATIONS}."
        )

InvalidImageFormat

Bases: Exception

Exception to raise when the image format is incorrect.

Source code in apple_health_parser/exceptions.py
62
63
64
65
66
67
68
69
70
class InvalidImageFormat(Exception):
    """
    Exception to raise when the image format is incorrect.
    """

    def __init__(self, format: str) -> None:
        super().__init__(
            f"Incorrect image format: '{format}'. Allowed formats: {ALLOWED_IMAGE_FORMATS}."
        )

InvalidOperation

Bases: Exception

Exception to raise when the operation is invalid.

Source code in apple_health_parser/exceptions.py
73
74
75
76
77
78
79
80
81
class InvalidOperation(Exception):
    """
    Exception to raise when the operation is invalid.
    """

    def __init__(self, operation: str | None) -> None:
        super().__init__(
            f"Operation '{operation}' is invalid. Allowed operations: {OPERATIONS}."
        )

InvalidOverviewType

Bases: Exception

Exception to raise when the overview type is invalid.

Source code in apple_health_parser/exceptions.py
84
85
86
87
88
89
90
91
92
class InvalidOverviewType(Exception):
    """
    Exception to raise when the overview type is invalid.
    """

    def __init__(self, overview_type: str) -> None:
        super().__init__(
            f"Flag '{overview_type}' is invalid. Allowed overview types: {OVERVIEW_TYPES}."
        )

InvalidSource

Bases: Exception

Exception to raise when the source is missing.

Source code in apple_health_parser/exceptions.py
 95
 96
 97
 98
 99
100
101
102
103
class InvalidSource(Exception):
    """
    Exception to raise when the source is missing.
    """

    def __init__(self, source: str, sources: list[str]) -> None:
        super().__init__(
            f"No records found for '{source}'. Available sources: {sources}."
        )

MissingFlag

Bases: Exception

Exception to raise when the flag is missing.

Source code in apple_health_parser/exceptions.py
 4
 5
 6
 7
 8
 9
10
class MissingFlag(Exception):
    """
    Exception to raise when the flag is missing.
    """

    def __init__(self, flag: str) -> None:
        super().__init__(f"Flag '{flag}' is missing in the data.")

MissingRecords

Bases: Exception

Exception to raise when records are missing.

Source code in apple_health_parser/exceptions.py
13
14
15
16
17
18
19
class MissingRecords(Exception):
    """
    Exception to raise when records are missing.
    """

    def __init__(self) -> None:
        super().__init__("No records found in the data.")

MissingYear

Bases: Exception

Exception to raise when there is no record for the given year.

Source code in apple_health_parser/exceptions.py
22
23
24
25
26
27
28
class MissingYear(Exception):
    """
    Exception to raise when there is no record for the given year.
    """

    def __init__(self, year: int, years: list[int]) -> None:
        super().__init__(f"No record for the year {year}. Available years: {years}.")