X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=exceptions.py;h=aa0aecbef67abd8320db01c71446cc7ca5a24617;hb=4b04fd1d5a14c5c4c7e0985e5376b4e2f879ef06;hp=3ce94d365774422252ab591303907d31ff65d1ba;hpb=bf508f86e1576736d18cab08edbca834456045ee;p=python_utils.git diff --git a/exceptions.py b/exceptions.py index 3ce94d3..aa0aecb 100644 --- a/exceptions.py +++ b/exceptions.py @@ -1,13 +1,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): - pass + """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)