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 9, 2021
1 parent f359b10 commit 0d667e8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion teuthology/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ class CommandFailedError(Exception):
Exception thrown on command failure
"""
def __init__(self, command, exitstatus, node=None, label=None):
self.command = command
if isinstance(command, (list, tuple)):
self.command = ' '.join(command)
elif instance(command, str):
self.command = command
else:
raise RuntimeError('variable "command" is not str, list or tuple')
self.exitstatus = exitstatus
self.node = node
self.label = label
Expand Down

0 comments on commit 0d667e8

Please sign in to comment.