-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathconfig_changes.py
More file actions
40 lines (27 loc) · 1.32 KB
/
config_changes.py
File metadata and controls
40 lines (27 loc) · 1.32 KB
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
30
31
32
33
34
35
36
37
38
39
40
"""Custom exception classes related to configuration changes."""
from typing import TYPE_CHECKING, override
from typed_classproperties import classproperty
from .base import BaseTeXBotError
if TYPE_CHECKING:
from collections.abc import Sequence
from collections.abc import Set as AbstractSet
__all__: "Sequence[str]" = ("ImproperlyConfiguredError", "RestartRequiredDueToConfigChange")
class ImproperlyConfiguredError(BaseTeXBotError, Exception):
"""Exception class to raise when environment variables are not correctly provided."""
@classproperty
@override
def DEFAULT_MESSAGE(cls) -> str:
return "One or more provided environment variable values are invalid."
class RestartRequiredDueToConfigChange(BaseTeXBotError, Exception): # noqa: N818
"""Exception class to raise when a restart is required to apply config changes."""
@classproperty
@override
def DEFAULT_MESSAGE(cls) -> str:
return "TeX-Bot requires a restart to apply configuration changes."
@override
def __init__(
self, message: str | None = None, changed_settings: "AbstractSet[str] | None" = None
) -> None:
"""Initialise an Exception to apply configuration changes."""
self.changed_settings: AbstractSet[str] | None = changed_settings or set()
super().__init__(message)