Settings loader, pass error messages to exception raise

So we can get the actual error message in the exception if logging is all off
This commit is contained in:
Clemens Schwaighofer
2025-12-24 10:08:38 +09:00
parent 17e8c76b94
commit d224876a8e
3 changed files with 29 additions and 1 deletions

View File

@@ -37,3 +37,6 @@ email_bad=gii@bar.com
[LoadTest]
a.b.c=foo
d:e:f=bar
[ErrorTest]
some_value=42

View File

@@ -125,6 +125,20 @@ def main():
except ValueError as e:
print(f"Could not load settings: {e}")
try:
config_load = 'ErrorTest'
config_data = sl.load_settings(
config_load,
{
"some_value": [
"check:string.email.basic",
],
}
)
print(f"[{config_load}] Load: {config_load} -> {dump_data(config_data)}")
except ValueError as e:
print(f"Could not load settings: {e}")
if __name__ == "__main__":
main()