diff --git a/monkey/common/configuration/agent_configuration.py b/monkey/common/configuration/agent_configuration.py index 097b86382..5b801610d 100644 --- a/monkey/common/configuration/agent_configuration.py +++ b/monkey/common/configuration/agent_configuration.py @@ -17,16 +17,19 @@ from .agent_sub_configurations import ( PropagationConfiguration, ) - -class InvalidConfigurationError(Exception): - pass - - INVALID_CONFIGURATION_ERROR_MESSAGE = ( "Cannot construct an AgentConfiguration object with the supplied, invalid data:" ) +class InvalidConfigurationError(Exception): + def __init__(self, message: str): + self._message = message + + def __str__(self) -> str: + return f"{INVALID_CONFIGURATION_ERROR_MESSAGE}: {self._message}" + + @dataclass(frozen=True) class AgentConfiguration: keep_tunnel_open_time: float @@ -42,7 +45,7 @@ class AgentConfiguration: try: AgentConfigurationSchema().dump(self) except Exception as err: - raise InvalidConfigurationError(f"{INVALID_CONFIGURATION_ERROR_MESSAGE}: {err}") + raise InvalidConfigurationError(err) @staticmethod def from_mapping(config_mapping: Mapping[str, Any]) -> AgentConfiguration: