"examples/git@developer.sourcefind.cn:OpenDAS/nni.git" did not exist on "816dd6035c88c80dafe3eeabaea90f32cb883273"
Unverified Commit ab9de209 authored by SparkSnail's avatar SparkSnail Committed by GitHub
Browse files

Show error message when load yaml file failed (#1012)

parent 8531d809
...@@ -32,9 +32,12 @@ def get_yml_content(file_path): ...@@ -32,9 +32,12 @@ def get_yml_content(file_path):
try: try:
with open(file_path, 'r') as file: with open(file_path, 'r') as file:
return yaml.load(file, Loader=yaml.Loader) return yaml.load(file, Loader=yaml.Loader)
except TypeError as err: except yaml.scanner.ScannerError as err:
print('Error: ', err) print_error('yaml file format error!')
return None exit(1)
except Exception as exception:
print_error(exception)
exit(1)
def get_json_content(file_path): def get_json_content(file_path):
'''Load json file content''' '''Load json file content'''
...@@ -42,7 +45,7 @@ def get_json_content(file_path): ...@@ -42,7 +45,7 @@ def get_json_content(file_path):
with open(file_path, 'r') as file: with open(file_path, 'r') as file:
return json.load(file) return json.load(file)
except TypeError as err: except TypeError as err:
print('Error: ', err) print_error('json file format error!')
return None return None
def print_error(content): def print_error(content):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment