diff --git a/avocado/core/exceptions.py b/avocado/core/exceptions.py index 7901b40cdc2beee76b42b7d666ff666c07475c8a..3f11a0962637b24c56036efea614f59a9c807a57 100644 --- a/avocado/core/exceptions.py +++ b/avocado/core/exceptions.py @@ -106,15 +106,18 @@ class TestWarn(TestBaseException): class CmdError(Exception): - def __init__(self, command, result): + def __init__(self, command=None, result=None): self.command = command self.result = result def __str__(self): - if self.result.exit_status is None: - msg = "Command '%s' failed and is not responding to signals" - msg %= self.command + if self.result is not None: + if self.result.exit_status is None: + msg = "Command '%s' failed and is not responding to signals" + msg %= self.command + else: + msg = "Command '%s' failed (rc=%d)" + msg %= (self.command, self.result.exit_status) + return msg else: - msg = "Command '%s' failed (rc=%d)" - msg %= (self.command, self.result.exit_status) - return msg + return "CmdError"