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