From f864346828508bae12738f4e9c1e9a649f3d40eb Mon Sep 17 00:00:00 2001 From: Xyphuz Date: Thu, 19 May 2022 00:34:53 +0800 Subject: [PATCH] feat: implement parser exceptions --- compose_viz/parser.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/compose_viz/parser.py b/compose_viz/parser.py index be545e8..fe90d56 100644 --- a/compose_viz/parser.py +++ b/compose_viz/parser.py @@ -16,16 +16,14 @@ class Parser: yaml = YAML(typ="safe", pure=True) yaml_data = yaml.load(f) 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 if not yaml_data: - print("Error: empty yaml file") - raise ValueError + raise RuntimeError("Empty yaml file, aborting.") if not yaml_data.get("services"): - print("Error: no services found") - raise ValueError + raise RuntimeError("No services found, aborting.") # parse services data into Service objects services_data = yaml_data["services"]