Coverage for jstark/exceptions.py: 100%
14 statements
« prev ^ index » next coverage.py v7.4.3, created at 2024-02-25 20:09 +0000
« prev ^ index » next coverage.py v7.4.3, created at 2024-02-25 20:09 +0000
1"""jstark exceptions
2"""
3from jstark.period_unit_of_measure import PeriodUnitOfMeasure
6class FeaturePeriodMnemonicIsInvalid(Exception):
7 """FeaturePeriod mnemonic doesn't match X[dqmqy]Y"""
9 def __str__(self) -> str:
10 return (
11 "FeaturePeriod mnemonic must be an integer followed by a letter "
12 + f"from {[e.value for e in PeriodUnitOfMeasure]} followed by an integer"
13 )
16class FeaturePeriodEndGreaterThanStartError(Exception):
17 """Exception indicating end of a feature period cannot be before the start"""
19 def __init__(self, start: int, end: int, *args: object) -> None:
20 super().__init__(*args)
21 self.start = start
22 self.end = end
24 def __str__(self) -> str:
25 return (
26 f"End of the feature period ({self.end}) cannot be "
27 + f"before the start of the feature period ({self.start})"
28 )
31class AsAtIsNotADate(Exception):
32 """Exception indicating a value must be of type date"""
34 def __str__(self) -> str:
35 return "as_at value must be of type date"