More cleanup.
[python_utils.git] / exceptions.py
1 #!/usr/bin/env python3
2
3 """Some exceptions used elsewhere."""
4
5 # This module is commonly used by others in here and should avoid
6 # taking any unnecessary dependencies back on them.
7
8
9 class PreconditionException(AssertionError):
10     """Use to indicate function preconditions violated."""
11
12     pass
13
14
15 class PostconditionException(AssertionError):
16     """Use to indicate function postconditions violated."""
17
18     pass
19
20
21 class TimeoutError(Exception):
22     """Use to indicate an operation that timed out."""
23
24     def __init__(self, value: str = "Timed out"):
25         super().__init__()
26         self.value = value
27
28     def __str__(self):
29         return repr(self.value)