Coverage for /usr/local/lib/python3.8/site-packages/spam/errors.py: 40%
10 statements
« prev ^ index » next coverage.py v7.2.3, created at 2023-11-22 13:26 +0000
« prev ^ index » next coverage.py v7.2.3, created at 2023-11-22 13:26 +0000
1class Error(Exception):
2 """Base class for exceptions in this module."""
3 pass
5class InputError(Error):
6 """Exception raised for errors in the input.
8 Attributes:
9 variable -- variable name which caused the error
10 explanation -- explanation of the error
11 """
13 def __init__(self, variable, explanation=None):
14 self.variable = variable
15 self.explanation = explanation
16 self.message = f"input error on variable {self.variable}"
17 if self.explanation is not None:
18 self.message += f' ({self.explanation})'
20 super().__init__(self.message)