Infrastructure for reporting configuration errors via exceptions

Once the actual config-parsing code start raising these exceptions
instead of directly calling sys.exit(), the user experience would
deteriorate due to raw exception traces. There's little value in the
trace itself, so just wrap the whole config loading with pretty error
formatting.

We still do not point to a specific place where that error is defined
(such as a line/column in a given JSON file) because that information is
already lost by the time we perform these checks.

Also, these checks are largely open-coded ad-hoc stuff. Some required
items are not covered, raising KeyError instead. We should get a formal
schema for these...
This commit is contained in:
Jan Kundrát
2019-05-29 18:15:55 +02:00
parent 783aaa8cb4
commit 71b157a8ba
3 changed files with 35 additions and 13 deletions

13
gnpy/core/exceptions.py Normal file
View File

@@ -0,0 +1,13 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
gnpy.core.exceptions
====================
Exceptions thrown by other gnpy modules
'''
class ConfigurationError(Exception):
'''User-provided configuration contains an error'''