fix: read_account_uri error handling

This commit is contained in:
dettlaff 2024-09-24 05:07:02 +04:00
parent 5b3bf524fc
commit 1d532d20f5

View file

@ -40,12 +40,14 @@ def read_account_uri() -> str:
try:
with ACCOUNT_PATH.open("r") as file:
account_info = json.load(file)
return account_info.get("registration", {}).get("uri", "URI not found")
return account_info["registration"]["uri"]
except FileNotFoundError:
print(f"Account file not found: {ACCOUNT_PATH}")
except json.JSONDecodeError:
print(f"Can't get URI from JSON file: {ACCOUNT_PATH}")
print(f"Can not decode JSON file: {ACCOUNT_PATH}")
except KeyError:
print(f"URI not found in JSON file {ACCOUNT_PATH}")
class ServiceManager(Service):