From ae45e7da733a367e93cff74a920cbdfcb1f22567 Mon Sep 17 00:00:00 2001 From: Alex MKX Date: Sat, 2 Dec 2023 19:48:13 +0400 Subject: [PATCH] Refine MissingParameter error messages Improved error handling by refining the MissingParameter exceptions in __init__.py. The changes provide more specific error messages when label or namespace parameters are missing for better debugging. --- docker_injector/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docker_injector/__init__.py b/docker_injector/__init__.py index 20ba29d..d294341 100644 --- a/docker_injector/__init__.py +++ b/docker_injector/__init__.py @@ -112,9 +112,8 @@ def shutdown_child(process: subprocess.Popen): @click.option("--cmd", prompt=False, default=lambda: os.environ.get("INJECTOR_CMD", None), help="The command to run in the namespace") def inject(label, require, ns, proc, cmd): - if label is None: - raise MissingParameter("Label is not specified") + raise MissingParameter("Label is not specified", param=label) l = re.split("[:=]", label) name = l[0] if len(l) == 2: @@ -122,7 +121,7 @@ def inject(label, require, ns, proc, cmd): else: value = None if ns is None: - raise MissingParameter("Namespaces are not specified") + raise MissingParameter("Namespaces are not specified", param=ns) nslist = ns.split(',') client = docker.from_env() if value is None: