summaryrefslogtreecommitdiff
path: root/exceptions.py
blob: aa0aecbef67abd8320db01c71446cc7ca5a24617 (plain)
1
2
3
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
#!/usr/bin/env python3

"""Some exceptions used elsewhere."""

# This module is commonly used by others in here and should avoid
# taking any unnecessary dependencies back on them.


class PreconditionException(AssertionError):
    """Use to indicate function preconditions violated."""

    pass


class PostconditionException(AssertionError):
    """Use to indicate function postconditions violated."""

    pass


class TimeoutError(Exception):
    """Use to indicate an operation that timed out."""

    def __init__(self, value: str = "Timed out"):
        super().__init__()
        self.value = value

    def __str__(self):
        return repr(self.value)