Improve ContainerError message compute

Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
Joffrey F 2017-08-07 12:05:40 -07:00 committed by Joffrey F
parent 62fda980e4
commit f3374959b7
1 changed files with 3 additions and 6 deletions

View File

@ -128,12 +128,9 @@ class ContainerError(DockerException):
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)