From d20ff112b7ce858056c5f5111d09f2705b25dced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20K=C3=B6ster?= Date: Mon, 30 Jan 2023 10:47:54 +0100 Subject: [PATCH] fix: better error handling when parsing package versions (#47) --- snakedeploy/conda.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/snakedeploy/conda.py b/snakedeploy/conda.py index 96b044a..8f7e26a 100644 --- a/snakedeploy/conda.py +++ b/snakedeploy/conda.py @@ -194,7 +194,12 @@ def get_pkg_versions(conda_env_path): def downgraded(): for pkg_name, version in posterior_pkg_versions.items(): - version = packaging_version.parse(version) + try: + version = packaging_version.parse(version) + except packaging_version.InvalidVersion as e: + raise UserError( + f"Cannot parse version {version} of package {pkg_name}: {e}" + ) prior_version = prior_pkg_versions.get(pkg_name) if prior_version is not None and version < packaging_version.parse( prior_version @@ -297,6 +302,9 @@ def add_file(self, filepath, content, is_updated, msg): @retry(tries=2, delay=60) def create(self): + import pdb + + pdb.set_trace() if not self.files: logger.info("No files to commit.") return