Skip to content

Commit

Permalink
Handle syntax errors in config gracefully
Browse files Browse the repository at this point in the history
Fix #233
  • Loading branch information
alichtman committed Oct 8, 2019
1 parent fe8fc0d commit a811656
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions shallow_backup/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ def get_config():
Returns the config.
:return: dictionary for config
"""
with open(get_config_path()) as f:
config = json.load(f)
config_path = get_config_path()
with open(config_path) as f:
try:
config = json.load(f)
except json.decoder.JSONDecodeError as e:
print_red_bold(f"ERROR: Invalid syntax in {config_path}")
sys.exit(1)
return config


Expand Down

0 comments on commit a811656

Please sign in to comment.