From f036713d718c179f838c54cf310c7ca9a26a4b22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Wed, 10 May 2023 16:23:32 +0200 Subject: [PATCH] improve some error messages --- src/ldaptool/_main.py | 2 +- src/ldaptool/search/config.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ldaptool/_main.py b/src/ldaptool/_main.py index 38fabb0..ac8d0b6 100644 --- a/src/ldaptool/_main.py +++ b/src/ldaptool/_main.py @@ -105,7 +105,7 @@ class _Context: try: self.config = search.Config.load() except Exception as e: - raise SystemExit(f"config error: {e}") + raise SystemExit(f"config error: {e!r}") try: self.arguments = arguments_p.from_args(args) except decode.InvalidStep as e: diff --git a/src/ldaptool/search/config.py b/src/ldaptool/search/config.py index 6ccda45..a8da6e3 100644 --- a/src/ldaptool/search/config.py +++ b/src/ldaptool/search/config.py @@ -29,7 +29,7 @@ class Realm: @staticmethod def load(name: str, data: typing.Any) -> Realm: - assert isinstance(data, dict) + assert isinstance(data, dict), f"Realm section isn't a dictionary: {data!r}" domain = data.pop("domain") servers = data.pop("servers").split() forest_root_domain = data.pop("forest_root_domain", domain) @@ -199,7 +199,7 @@ class Config: with open(conf_path) as f: data = yaml.safe_load(f) assert isinstance(data, dict) - assert "realms" in data + assert "realms" in data, "Missing realms section in config" realms_data = data.pop("realms") assert isinstance(realms_data, dict) realms = {}