From f3374959b7145d0c25042d51065b5d387832d19c Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Mon, 7 Aug 2017 12:05:40 -0700 Subject: [PATCH] Improve ContainerError message compute Signed-off-by: Joffrey F --- docker/errors.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/docker/errors.py b/docker/errors.py index 1f8ac23c4..2a2f871e5 100644 --- a/docker/errors.py +++ b/docker/errors.py @@ -128,12 +128,9 @@ def __init__(self, container, exit_status, command, image, stderr): self.image = image self.stderr = stderr - if stderr is None: - msg = ("Command '{}' in image '{}' returned non-zero exit " - "status {}").format(command, image, exit_status, stderr) - else: - msg = ("Command '{}' in image '{}' returned non-zero exit " - "status {}: {}").format(command, image, exit_status, stderr) + err = ": {}".format(stderr) if stderr is not None else "" + msg = ("Command '{}' in image '{}' returned non-zero exit " + "status {}{}").format(command, image, exit_status, err) super(ContainerError, self).__init__(msg)