import json
from pathlib import Path
from pydantic import BaseModel, ValidationError


class Config(BaseModel):
    data_path: Path
    responses_path: Path

    @classmethod
    def load_config(cls, config_path: Path) -> 'Config':
        try:
            with config_path.open('r', encoding='utf-8') as config_file:
                config_data = json.load(config_file)
            return cls(**config_data)
        except FileNotFoundError:
            print("Config file not found.")
            exit(1)
        except json.JSONDecodeError:
            print("Invalid JSON.")
            exit(1)
        except ValidationError as e:
            print(f"Configuration validation error: {e}")
            exit(1)