blob: d82775b066b615d76af5f941260d4bd65f78e256 [file] [log] [blame]
mbligh05269362007-10-16 16:58:11 +00001"""
2Internal global error types
3"""
4
5import sys
6from traceback import format_exception
7
8def format_error():
9 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 = ''
14
15 return ''.join(trace)
16
17class JobContinue(SystemExit):
18 """Allow us to bail out requesting continuance."""
19 pass
20
21class AutotestError(Exception):
22 """The parent of all errors deliberatly thrown within the client code."""
23 pass
24
25class JobError(AutotestError):
26 """Indicates an error which terminates and fails the whole job."""
27 pass
28
29class TestError(AutotestError):
30 """Indicates an error which terminates and fails the test."""
31 pass
32
33class CmdError(TestError):
34 """Indicates that a command failed, is fatal to the test unless caught."""
35 def __str__(self):
36 return "Command <" + self.args[0] + "> failed, rc=%d" % (self.args[1])
37
38class UnhandledError(TestError):
39 """Indicates an unhandled exception in a test."""
40 def __init__(self, prefix):
mblighbbdbfd12007-11-28 16:36:41 +000041 msg = prefix + format_error()
42 TestError.__init__(self, msg)