mirror of
https://github.com/cupcakearmy/glyphance.git
synced 2024-12-21 23:56:32 +00:00
error handling on config load
This commit is contained in:
parent
61d4f0e52e
commit
a77f6f1c06
@ -1,5 +1,6 @@
|
||||
import os
|
||||
|
||||
import click
|
||||
import jsonschema
|
||||
import yaml
|
||||
|
||||
@ -31,9 +32,17 @@ def validate(config):
|
||||
|
||||
def load(path):
|
||||
# Load config
|
||||
try:
|
||||
path = os.path.abspath(path)
|
||||
with open(path, 'r') as f:
|
||||
config = yaml.safe_load(f)
|
||||
except FileNotFoundError:
|
||||
click.echo(f"Config file not found: {path}")
|
||||
exit(1)
|
||||
except yaml.YAMLError as e:
|
||||
click.echo(f"Config file is not valid YAML: {path}")
|
||||
click.echo(e)
|
||||
exit(1)
|
||||
|
||||
# Setting dynamic defaults
|
||||
default_config['context'] = os.path.dirname(path)
|
||||
|
Loading…
Reference in New Issue
Block a user