Commit 6e297d46 authored by Pierre Dittgen's avatar Pierre Dittgen
Browse files

Improve config error logging

parent 021199a2
......@@ -7,6 +7,7 @@ from pathlib import Path
import requests
import toml
from dotenv import load_dotenv
from pydantic.error_wrappers import ValidationError
from . model import Config
......@@ -51,8 +52,14 @@ CONFIG = None
if CONFIG_FILE:
CONFIG_FILE = Path(CONFIG_FILE)
with CONFIG_FILE.open() as fd:
config_dict = yaml.full_load(fd)
CONFIG = Config.parse_obj(config_dict)
try:
config_dict = yaml.full_load(fd)
except yaml.scanner.ScannerError as exc:
raise ValueError(f"Could not load YAML config file {CONFIG_FILE}") from exc
try:
CONFIG = Config.parse_obj(config_dict)
except ValidationError as exc:
raise ValueError(f"Invalid config from {CONFIG_FILE}") from exc
MATOMO_BASE_URL = os.getenv("MATOMO_BASE_URL") or None
if MATOMO_BASE_URL:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment