Skip to content

Commit

Permalink
exceptions: change error message for CommandFailedError
Browse files Browse the repository at this point in the history
For the convenience of user, print the command that led to
CommandFailedError in error message as a str than as a list or a tuple.
This makes it more readable and enables the user to copy and use the
command without any hassles.

Signed-off-by: Rishabh Dave <[email protected]>
  • Loading branch information
rishabh-d-dave committed Jun 14, 2021
1 parent f359b10 commit 9013aa6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions teuthology/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ def __init__(self, command, exitstatus, node=None, label=None):
self.label = label

def __str__(self):
if isinstance(self.command, (list, tuple)):
self.command = ' '.join(self.command)
elif not isinstance(self.command, str):
raise RuntimeError('variable "command" is not str, list or tuple')

prefix = "Command failed"
if self.label:
prefix += " ({label})".format(label=self.label)
Expand Down

0 comments on commit 9013aa6

Please sign in to comment.