From 8045a6643db03cead38540d1c060ff647fdd9eb6 Mon Sep 17 00:00:00 2001 From: "Samuel Hierholzer (Adfinis AG)" Date: Wed, 24 Jul 2024 10:23:23 +0200 Subject: [PATCH] fix: Properly fail if publish hasn't been created yet --- pyaptly/publish.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyaptly/publish.py b/pyaptly/publish.py index c79a2cf..bb18a83 100644 --- a/pyaptly/publish.py +++ b/pyaptly/publish.py @@ -85,10 +85,12 @@ def publish_cmd_update(cfg, publish_name, publish_config, ignore_existing=False) return cmd publish_fullname = "%s %s" % (publish_name, publish_config["distribution"]) - # This line might fail if no publish has been created yet - # TODO: add clag --create to create publishes when they haven't been created yet + # TODO: add flag --create to create publishes when they haven't been created yet # TODO: Fail gracefully and show an error when there is no existing publish - current_snapshots = state_reader.state_reader().publish_map()[publish_fullname] + try: + current_snapshots = state_reader.state_reader().publish_map()[publish_fullname] + except KeyError as e: + util.exit_with_error("The publish hasn't been created yet: " + e) if "snapshots" in publish_config: snapshots_config = publish_config["snapshots"] new_snapshots = [