Skip to content

Commit

Permalink
Fix cli crash if no credential files given
Browse files Browse the repository at this point in the history
  • Loading branch information
laggykiller committed Feb 8, 2024
1 parent 03c993e commit 8afea7f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/sticker_convert/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,14 @@ def get_opt_comp(self, args: Namespace) -> CompOption:
def get_opt_cred(self, args: Namespace) -> CredOption:
creds_path = CONFIG_DIR / "creds.json"
creds = {}
try:
creds = JsonManager.load_json(creds_path)
except JSONDecodeError:
self.cb.msg("Warning: creds.json content is corrupted")
if creds_path.is_file():
try:
creds = JsonManager.load_json(creds_path)
except JSONDecodeError:
self.cb.msg("Warning: creds.json content is corrupted")
creds = {}
else:
creds = {}

if creds:
self.cb.msg("Loaded credentials from creds.json")
Expand Down

0 comments on commit 8afea7f

Please sign in to comment.