1"""Exception classes for qemu runner.""" 2 3 4class RunnerError(Exception): 5 """Contains all kinds of errors .run() will intentionally throw.""" 6 7 8class RunnerGenericError(RunnerError): 9 """Generic runner error message.""" 10 11 def __init__(self, msg): 12 super(RunnerGenericError, self).__init__() 13 self.msg = msg 14 15 def __str__(self): 16 return "Runner failed: %s" % self.msg 17 18 19class ConfigError(RunnerError): 20 """Invalid configuration.""" 21 22 def __init__(self, msg): 23 super(ConfigError, self).__init__() 24 self.msg = msg 25 26 def __str__(self): 27 return "Invalid configuration: %s" % self.msg 28 29 30class AdbFailure(RunnerError): 31 """An adb invocation failed.""" 32 33 def __init__(self, adb_args, code): 34 super(AdbFailure, self).__init__(self) 35 self.adb_args = adb_args 36 self.code = code 37 38 def __str__(self): 39 return "'adb %s' failed with %d" % (" ".join(self.adb_args), self.code) 40 41 42class Timeout(RunnerError): 43 """A step timed out.""" 44 45 def __init__(self, step, timeout): 46 super(Timeout, self).__init__(self) 47 self.step = step 48 self.timeout = timeout 49 50 def __str__(self): 51 return "%s timed out (%d s)" % (self.step, self.timeout) 52