Skip to content

Commit

Permalink
add another error check
Browse files Browse the repository at this point in the history
  • Loading branch information
acockburn committed Sep 18, 2024
1 parent 270c4b4 commit 64ed9ee
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions appdaemon/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,11 @@ def main(self): # noqa: C901
break
else:
# We have a config dir and a list of candidate names
if not os.path.isdir(config_dir):
print("FATAL: unable to locate configuration directory\n")
parser.print_help()
sys.exit(1)

for file in file_candidates:
config_file_path = os.path.join(config_dir, file)
if os.path.isfile(config_file_path):
Expand All @@ -280,14 +285,14 @@ def main(self): # noqa: C901
config_file_path = None

if config_file_path is None:
print("FATAL: unable to locate configuration path and/or configuration file\n")
print("FATAL: unable to locate configuration file\n")
parser.print_help()
sys.exit(1)

try:
config = utils.read_config_file(config_file_path)
except Exception as e:
print(f"Unexpected error loading config file: {config_file_path}")
print(f"FATAL: Unexpected error loading config file: {config_file_path}")
print(e)
sys.exit()

Expand Down

0 comments on commit 64ed9ee

Please sign in to comment.