Skip to content

Exceptions Class Reference

Module defining all custom exceptions for the AMR Hub ABM simulation.

The exceptions defined in this module are

  • SimulationModeError: When an operation is invalid for the given simulation mode.
  • InvalidDistanceError: When an invalid distance calculation is attempted.
  • TimeError: When a negative time value is encountered.
  • InvalidRoomError: When a room is defined with invalid parameters.
  • InvalidDoorError: When a door is defined with invalid parameters.
  • InvalidDefinitionError: When a general invalid definition is encountered.

InvalidDefinitionError

Bases: Exception

Exception raised when a general invalid definition is encountered.

Attributes:

Name Type Description
message str

A description of the error that occurred.

Source code in src/amr_hub_abm/exceptions.py
123
124
125
126
127
128
129
130
131
132
133
134
135
136
class InvalidDefinitionError(Exception):
    """
    Exception raised when a general invalid definition is encountered.

    Attributes
    ----------
    message : str
        A description of the error that occurred.

    """

    def __init__(self, message: str) -> None:
        """Initialize the InvalidDefinitionError."""
        super().__init__(f"Invalid definition: {message}.")

__init__(message)

Initialize the InvalidDefinitionError.

Source code in src/amr_hub_abm/exceptions.py
134
135
136
def __init__(self, message: str) -> None:
    """Initialize the InvalidDefinitionError."""
    super().__init__(f"Invalid definition: {message}.")

InvalidDistanceError

Bases: Exception

Exception raised when an invalid distance calculation is attempted.

This exception is used to indicate that a distance calculation between two locations is invalid, either because the locations are not compatible (e.g., different buildings).

Attributes:

Name Type Description
locations tuple

A tuple containing the two locations involved in the distance calculation.

building bool

A flag indicating whether the distance calculation is between buildings (True) or floors (False).

Source code in src/amr_hub_abm/exceptions.py
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
class InvalidDistanceError(Exception):
    """
    Exception raised when an invalid distance calculation is attempted.

    This exception is used to indicate that a distance calculation between two locations
    is invalid, either because the locations are not compatible
    (e.g., different buildings).

    Attributes
    ----------
    locations : tuple
        A tuple containing the two locations involved in the distance
        calculation.

    building : bool
        A flag indicating whether the distance calculation is between
        buildings (True) or floors (False).

    """

    def __init__(self, locations: tuple, building: bool) -> None:  # noqa: FBT001
        """Initialize the InvalidDistanceError."""
        initial_string = "Invalid distance calculation between"

        if building:
            super().__init__(
                f"{initial_string} buildings: {locations[0]} and {locations[1]}."
            )
        else:
            super().__init__(
                f"{initial_string} floors: {locations[0]} and {locations[1]}."
            )

__init__(locations, building)

Initialize the InvalidDistanceError.

Source code in src/amr_hub_abm/exceptions.py
54
55
56
57
58
59
60
61
62
63
64
65
def __init__(self, locations: tuple, building: bool) -> None:  # noqa: FBT001
    """Initialize the InvalidDistanceError."""
    initial_string = "Invalid distance calculation between"

    if building:
        super().__init__(
            f"{initial_string} buildings: {locations[0]} and {locations[1]}."
        )
    else:
        super().__init__(
            f"{initial_string} floors: {locations[0]} and {locations[1]}."
        )

InvalidDoorError

Bases: Exception

Exception raised when a door is defined with invalid parameters.

Attributes:

Name Type Description
message str

A description of the error that occurred.

Source code in src/amr_hub_abm/exceptions.py
107
108
109
110
111
112
113
114
115
116
117
118
119
120
class InvalidDoorError(Exception):
    """
    Exception raised when a door is defined with invalid parameters.

    Attributes
    ----------
    message : str
        A description of the error that occurred.

    """

    def __init__(self, message: str) -> None:
        """Initialize the InvalidDoorError."""
        super().__init__(f"Invalid door definition: {message}.")

__init__(message)

Initialize the InvalidDoorError.

Source code in src/amr_hub_abm/exceptions.py
118
119
120
def __init__(self, message: str) -> None:
    """Initialize the InvalidDoorError."""
    super().__init__(f"Invalid door definition: {message}.")

InvalidRoomError

Bases: Exception

Exception raised when a room is defined with invalid parameters.

This exception is used to indicate that a room definition is invalid, either because of missing parameters, incompatible parameters, or other issues with the room definition.

Attributes:

Name Type Description
message str

A description of the error that occurred.

Source code in src/amr_hub_abm/exceptions.py
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
class InvalidRoomError(Exception):
    """
    Exception raised when a room is defined with invalid parameters.

    This exception is used to indicate that a room definition is invalid, either
    because of missing parameters, incompatible parameters, or other issues with the
    room definition.

    Attributes
    ----------
    message : str
        A description of the error that occurred.

    """

    def __init__(self, message: str) -> None:
        """Initialize the InvalidRoomError."""
        super().__init__(f"Invalid room definition: {message}.")

__init__(message)

Initialize the InvalidRoomError.

Source code in src/amr_hub_abm/exceptions.py
102
103
104
def __init__(self, message: str) -> None:
    """Initialize the InvalidRoomError."""
    super().__init__(f"Invalid room definition: {message}.")

LocationDataValidationError

Bases: Exception

Exception raised when location-event input fails preflight validation.

Source code in src/amr_hub_abm/exceptions.py
155
156
157
158
159
160
161
162
163
164
165
166
167
class LocationDataValidationError(Exception):
    """Exception raised when location-event input fails preflight validation."""

    def __init__(
        self,
        errors: tuple[str, ...],
        warnings: tuple[str, ...] = (),
    ) -> None:
        """Initialize the error with all collected validation findings."""
        self.errors = errors
        self.warnings = warnings
        details = "\n".join(f"- {error}" for error in errors)
        super().__init__(f"Location data validation failed:\n{details}")

__init__(errors, warnings=())

Initialize the error with all collected validation findings.

Source code in src/amr_hub_abm/exceptions.py
158
159
160
161
162
163
164
165
166
167
def __init__(
    self,
    errors: tuple[str, ...],
    warnings: tuple[str, ...] = (),
) -> None:
    """Initialize the error with all collected validation findings."""
    self.errors = errors
    self.warnings = warnings
    details = "\n".join(f"- {error}" for error in errors)
    super().__init__(f"Location data validation failed:\n{details}")

NonNegativeValueError

Bases: Exception

Exception raised when a non-negative value is expected but not provided.

Attributes:

Name Type Description
message str

A description of the error that occurred.

Source code in src/amr_hub_abm/exceptions.py
139
140
141
142
143
144
145
146
147
148
149
150
151
152
class NonNegativeValueError(Exception):
    """
    Exception raised when a non-negative value is expected but not provided.

    Attributes
    ----------
    message : str
        A description of the error that occurred.

    """

    def __init__(self, message: str) -> None:
        """Initialize the NonNegativeValueError."""
        super().__init__(f"Non-negative value error: {message}.")

__init__(message)

Initialize the NonNegativeValueError.

Source code in src/amr_hub_abm/exceptions.py
150
151
152
def __init__(self, message: str) -> None:
    """Initialize the NonNegativeValueError."""
    super().__init__(f"Non-negative value error: {message}.")

SimulationModeError

Bases: Exception

Exception raised when an operation is invalid for the current simulation mode.

This exception is used to indicate that a certain action or operation cannot be performed because it is not compatible with the current simulation mode.

Attributes:

Name Type Description
message str

A description of the error that occurred.

Source code in src/amr_hub_abm/exceptions.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
class SimulationModeError(Exception):
    """
    Exception raised when an operation is invalid for the current simulation mode.

    This exception is used to indicate that a certain action or operation cannot be
    performed because it is not compatible with the current simulation mode.

    Attributes
    ----------
    message : str
        A description of the error that occurred.

    """

    def __init__(self, message: str) -> None:
        """Initialize the SimulationModeError."""
        super().__init__(f"Simulation mode error: {message}.")

__init__(message)

Initialize the SimulationModeError.

Source code in src/amr_hub_abm/exceptions.py
29
30
31
def __init__(self, message: str) -> None:
    """Initialize the SimulationModeError."""
    super().__init__(f"Simulation mode error: {message}.")

TimeError

Bases: Exception

Exception raised when a negative time value is encountered.

This exception is used to indicate that a time value provided to a function or method is negative, which is invalid in the context of the simulation.

Attributes:

Name Type Description
message str

A description of the error that occurred.

Source code in src/amr_hub_abm/exceptions.py
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
class TimeError(Exception):
    """
    Exception raised when a negative time value is encountered.

    This exception is used to indicate that a time value provided to a function or
    method is negative, which is invalid in the context of the simulation.

    Attributes
    ----------
    message : str
        A description of the error that occurred.

    """

    def __init__(self, message: str) -> None:
        """Initialize the TimeError."""
        super().__init__(f"Invalid time value encountered: {message}.")

__init__(message)

Initialize the TimeError.

Source code in src/amr_hub_abm/exceptions.py
82
83
84
def __init__(self, message: str) -> None:
    """Initialize the TimeError."""
    super().__init__(f"Invalid time value encountered: {message}.")