Skip to content

Commit

Permalink
❌ Handle file format error
Browse files Browse the repository at this point in the history
Issue: #10
  • Loading branch information
gopinath-langote committed Apr 25, 2019
1 parent 95a48f4 commit e0f8278
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions 1build
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@ def parse_project_config():
with open("1build.yaml", 'r') as stream:
try:
content = yaml.safe_load(stream)
except yaml.YAMLError, exc:
return Project(name=(content["project"]), commands=(get_command_list_from_config(content["commands"])))
except:
raise ValueError(
"Error in parsing `1build.yaml` config file. Make sure file is in correct format. \n\n" + exc.__str__()
"Error in parsing `1build.yaml` config file. Make sure file is in correct format. \nSample format is: \n\n" +
"---------------------------------------------------\n" + sample_yaml_file() + "---------------------------------------------------\n"
)
return Project(name=(content["project"]), commands=(get_command_list_from_config(content["commands"])))
else:
raise ValueError("No `1build.yaml` file found in current directory.")

Expand All @@ -102,4 +103,16 @@ def command_to_run(arguments):
return arguments[1]


def sample_yaml_file():
return "project: JUnit5" + "\n" + \
"commands:" + "\n" + \
" - build:" + "\n" + \
" description: build the project" + "\n" + \
" cmd: ./gradlew clean build" + "\n" + \
" - lint:" + "\n" + \
" description: fix the lint" + "\n" + \
" cmd: ./gradlew spotlessApply" + "\n" + \
""


run(sys.argv)

0 comments on commit e0f8278

Please sign in to comment.