feat: implement parser exceptions
This commit is contained in:
parent
650fc9dc46
commit
f864346828
1 changed files with 3 additions and 5 deletions
|
@ -16,16 +16,14 @@ class Parser:
|
||||||
yaml = YAML(typ="safe", pure=True)
|
yaml = YAML(typ="safe", pure=True)
|
||||||
yaml_data = yaml.load(f)
|
yaml_data = yaml.load(f)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise Exception(f"Error parsing file {file_path}: {e}")
|
raise RuntimeError(f"Error parsing file '{file_path}': {e}")
|
||||||
|
|
||||||
# validate the yaml file
|
# validate the yaml file
|
||||||
if not yaml_data:
|
if not yaml_data:
|
||||||
print("Error: empty yaml file")
|
raise RuntimeError("Empty yaml file, aborting.")
|
||||||
raise ValueError
|
|
||||||
|
|
||||||
if not yaml_data.get("services"):
|
if not yaml_data.get("services"):
|
||||||
print("Error: no services found")
|
raise RuntimeError("No services found, aborting.")
|
||||||
raise ValueError
|
|
||||||
|
|
||||||
# parse services data into Service objects
|
# parse services data into Service objects
|
||||||
services_data = yaml_data["services"]
|
services_data = yaml_data["services"]
|
||||||
|
|
Loading…
Reference in a new issue