Skip to content

Commit

Permalink
❌ Handle file not found case
Browse files Browse the repository at this point in the history
Issue: #10
  • Loading branch information
gopinath-langote committed Apr 25, 2019
1 parent b5b4744 commit 95a48f4
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions 1build
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,17 @@ def get_command_list_from_config(raw_string):


def parse_project_config():
with open("1build.yaml", 'r') as stream:
try:
content = yaml.safe_load(stream)
except yaml.YAMLError, exc:
raise ValueError(
"Error in parsing `1build.yaml` config file. Make sure file is in correct format. \n\n" + exc.__str__()
)
return Project(name=(content["project"]), commands=(get_command_list_from_config(content["commands"])))
if os.path.exists("1build.yaml"):
with open("1build.yaml", 'r') as stream:
try:
content = yaml.safe_load(stream)
except yaml.YAMLError, exc:
raise ValueError(
"Error in parsing `1build.yaml` config file. Make sure file is in correct format. \n\n" + exc.__str__()
)
return Project(name=(content["project"]), commands=(get_command_list_from_config(content["commands"])))
else:
raise ValueError("No `1build.yaml` file found in current directory.")


def help_message(project):
Expand Down

0 comments on commit 95a48f4

Please sign in to comment.