check if config_path exists

This commit is contained in:
Hirad 2025-07-17 15:10:33 +03:30
parent 41b22d049e
commit 77df7ece34

View file

@ -12,13 +12,15 @@ class SettingsManager:
def __init__(self, config_path: Path = DEFAULT_PATH) -> None:
self.config_path = config_path
def load_config(self) -> SynapseConfig:
def load_config(self) -> SynapseConfig | None:
"""Load Synapse configuration from YAML file with validation."""
try:
if not self.config_path.exists():
return None
with self.config_path.open('r', encoding="utf-8") as f:
config_data = yaml.safe_load(f)
except FileNotFoundError:
raise FileNotFoundError(f"Config file not found: {self.config_path}") from None
None
except yaml.YAMLError as e:
raise ValueError(f"Invalid YAML syntax: {e}") from e