Skip to content

Commit

Permalink
Refine MissingParameter error messages
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AlexMKX committed Dec 2, 2023
1 parent 986a0cd commit ae45e7d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions docker_injector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,16 @@ 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:
value = l[1]
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:
Expand Down

0 comments on commit ae45e7d

Please sign in to comment.