Debian Codegraph @

recurring_ical_events/errors.py

raw symbols SCIP
1 """All the errors."""
2
3 from recurring_ical_events.types import Time
4
5
6 class InvalidCalendar(ValueError):
7 """Exception thrown for bad icalendar content."""
8
9 def __init__(self, message: str):
10 """Create a new error with a message."""
11 self._message = message
12 super().__init__(self.message)
13
14 @property
15 def message(self) -> str:
16 """The error message."""
17 return self._message
18
19
20 class PeriodEndBeforeStart(InvalidCalendar):
21 """An event or component starts before it ends."""
22
23 def __init__(self, message: str, start: Time, end: Time):
24 """Create a new PeriodEndBeforeStart error."""
25 super().__init__(message)
26 self._start = start
27 self._end = end
28
29 @property
30 def start(self) -> Time:
31 """The start of the component's period."""
32 return self._start
33
34 @property
35 def end(self) -> Time:
36 """The end of the component's period."""
37 return self._end
38
39
40 class BadRuleStringFormat(InvalidCalendar):
41 """An iCal rule string is badly formatted."""
42
43 def __init__(self, message: str, rule: str):
44 """Create an error with a bad rule string."""
45 super().__init__(message + ": " + rule)
46 self._rule = rule
47
48 @property
49 def rule(self) -> str:
50 """The malformed rule string"""
51 return self._rule
52
53
54 __all__ = ["BadRuleStringFormat", "InvalidCalendar", "PeriodEndBeforeStart"]