From c0b55022ec185ebf389657ac0cc26f6cb93344cd Mon Sep 17 00:00:00 2001 From: "s. rannou" Date: Tue, 21 Nov 2023 12:12:28 +0100 Subject: [PATCH] feat: pretty print config errors --- etc/config.local.yaml | 4 ++-- eth_validator_watcher/entrypoint.py | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/etc/config.local.yaml b/etc/config.local.yaml index 74f75d5..b5122d8 100644 --- a/etc/config.local.yaml +++ b/etc/config.local.yaml @@ -11,6 +11,6 @@ relays: ~ liveness_file: ~ watched_keys: - - public_key: 0x832b8286f5d6535fd941c6c4ed8b9b20d214fc6aa726ce4fba1c9dbb4f278132646304f550e557231b6932aa02cf08d3 - labels: ["google"] + - public_key: '0x832b8286f5d6535fd941c6c4ed8b9b20d214fc6aa726ce4fba1c9dbb4f278132646304f550e557231b6932aa02cf08d3' + labels: ['google'] fee_recipient: ~ diff --git a/eth_validator_watcher/entrypoint.py b/eth_validator_watcher/entrypoint.py index 768cc9c..7dee7a9 100644 --- a/eth_validator_watcher/entrypoint.py +++ b/eth_validator_watcher/entrypoint.py @@ -9,6 +9,7 @@ import typer from prometheus_client import Gauge, start_http_server from typer import Option +from pydantic import ValidationError from .beacon import Beacon from .config import load_config, WatchedKeyConfig @@ -136,7 +137,10 @@ def handler( Prometheus server is automatically exposed on port 8000. """ - cfg = load_config(config) + try: + cfg = load_config(config) + except ValidationError as err: + raise typer.BadParameter(f'Invalid configuration file: {err}') try: # pragma: no cover _handler( @@ -148,7 +152,7 @@ def handler( cfg.slack_channel, cfg.slack_token, cfg.beacon_type, - cfg.relay_url, + cfg.relays, cfg.liveness_file, ) except KeyboardInterrupt: # pragma: no cover