Skip to content

Commit

Permalink
Config syntax error handling (#234)
Browse files Browse the repository at this point in the history
* Handle syntax errors in config gracefully

Fix #233

* Bump version to v2.7
  • Loading branch information
alichtman authored Oct 8, 2019
1 parent fe8fc0d commit a5bec6f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 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
2 changes: 1 addition & 1 deletion shallow_backup/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class ProjInfo:
PROJECT_NAME = 'shallow-backup'
VERSION = '2.6'
VERSION = '2.7'
AUTHOR_GITHUB = 'alichtman'
AUTHOR_FULL_NAME = 'Aaron Lichtman'
DESCRIPTION = "Easily create lightweight backups of installed packages, dotfiles, and more."
Expand Down

0 comments on commit a5bec6f

Please sign in to comment.