endlessm / azafea

Service to track device activations and usage metrics
Mozilla Public License 2.0
10 stars 2 forks source link

Better handle missing configuration options #2

Open bochecha opened 5 years ago

bochecha commented 5 years ago

The config system is nice in that it validates the configuration, and specifically the types of the options, hopefully giving administrators good error messages about what failed.

But try it with the following configuration:

[queues.te]

And you get a completely mystifying error:

Traceback (most recent call last):
  File "/usr/lib64/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib64/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/mathieu/Projects/endless/azafea/azafea/__main__.py", line 26, in <module>
    sys.exit(args.subcommand(args))
  File "/home/mathieu/Projects/endless/azafea/azafea/cli.py", line 120, in do_print_config
    config = Config.from_file(args.config)
  File "/home/mathieu/Projects/endless/azafea/azafea/config/__init__.py", line 177, in from_file
    queues[name] = Queue(**queue_options)
TypeError: __init__() missing 1 required positional argument: 'handler'

We should be able to do better.

bochecha commented 4 years ago

This is slightly better with the current master:

[ERROR] azafea.cli: Invalid configuration:
* queues.te: __init__() missing 1 required positional argument: 'handler'

Still unclear, but at least that's not a scary traceback any more. +1