blob: 720cb9c24a36cd7e27d93b1fdbf5b5e5355561d7 [file] [log] [blame]
mbligh906b9f72007-11-29 18:56:17 +00001"""
2Internal global error types
3"""
4
5import sys
6from traceback import format_exception
7
8def format_error():
mbligh642b03e2008-01-14 16:53:15 +00009 t, o, tb = sys.exc_info()
10 trace = format_exception(t, o, tb)
11 # Clear the backtrace to prevent a circular reference
12 # in the heap -- as per tutorial
13 tb = ''
mbligh906b9f72007-11-29 18:56:17 +000014
mbligh642b03e2008-01-14 16:53:15 +000015 return ''.join(trace)
mbligh906b9f72007-11-29 18:56:17 +000016
17class JobContinue(SystemExit):
18 """Allow us to bail out requesting continuance."""
19 pass
20
21class JobComplete(SystemExit):
22 """Allow us to bail out indicating continuation not required."""
23 pass
24
25class AutotestError(Exception):
26 """The parent of all errors deliberatly thrown within the client code."""
27 pass
28
29class JobError(AutotestError):
30 """Indicates an error which terminates and fails the whole job."""
31 pass
32
33class TestError(AutotestError):
34 """Indicates an error which terminates and fails the test."""
35 pass
36
37class CmdError(TestError):
38 """Indicates that a command failed, is fatal to the test unless caught."""
39 def __str__(self):
40 return "Command <" + self.args[0] + "> failed, rc=%d" % (self.args[1])
41
42class PackageError(TestError):
mbligh642b03e2008-01-14 16:53:15 +000043 """Indicates an error trying to perform a package operation."""
44 pass
mbligh906b9f72007-11-29 18:56:17 +000045
46class UnhandledError(TestError):
47 """Indicates an unhandled exception in a test."""
48 def __init__(self, prefix):
49 msg = prefix + format_error()
50 TestError.__init__(self, msg)
mbligh03f4fc72007-11-29 20:56:14 +000051
mbligh5deff3d2008-01-04 21:21:28 +000052class InstallError(JobError):
53 """Indicates an installation error which Terminates and fails the job."""
54 pass
mbligh03f4fc72007-11-29 20:56:14 +000055
56# server-specific errors
57
58class AutoservError(Exception):
59 pass
60
61
62class AutoservRunError(AutoservError):
63 """Errors raised by one of the run functions"""
64 pass
65
66
67class AutoservVirtError(AutoservError):
68 """Vitualization related error"""
69 pass
70
71
72class AutoservUnsupportedError(AutoservError):
73 """Error raised when you try to use an unsupported optional feature"""
74 pass
75
76class AutoservHostError(AutoservError):
77 """Error reaching a host"""
78 pass
79
80class AutoservRebootError(AutoservError):
81 """Error occured while rebooting a machine"""
82 pass