check if config_path exists
This commit is contained in:
parent
41b22d049e
commit
77df7ece34
1 changed files with 4 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue