Adds an UnhandledJobError exception and JobNAError exception.

When executing steps in the step engine, catch JobNAError and record it
as a TEST_NA and continue on to the next step.  Turn all other
non-SystemExit exceptions into an UnhandledJobError wrapping the
original.

This allows control files and othe common code to raise
error.JobNAError to indicate that a particular thing in a multi-test
(step) control file cannot be run but should not cause the entire job
to abort.

Signed-off-by: Gregory Smith <gps@google.com>



git-svn-id: http://test.kernel.org/svn/autotest/trunk@2534 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/common_lib/error.py b/client/common_lib/error.py
index 8c002aa..f4be000 100644
--- a/client/common_lib/error.py
+++ b/client/common_lib/error.py
@@ -20,6 +20,7 @@
 
     return ''.join(trace)
 
+
 class JobContinue(SystemExit):
     """Allow us to bail out requesting continuance."""
     pass
@@ -36,10 +37,29 @@
 
 
 class JobError(AutotestError):
-    """Indicates an error which terminates and fails the whole job."""
+    """Indicates an error which terminates and fails the whole job (ABORT)."""
     pass
 
 
+class JobNAError(JobError):
+    """Indicates an error to skip this part of the whole job or fail it if
+    this was not a multi-step job."""
+    pass
+
+
+class UnhandledJobError(JobError):
+    """Indicates an unhandled error in a job."""
+    def __init__(self, unhandled_exception):
+        if isinstance(unhandled_exception, JobError):
+            TestError.__init__(self, *unhandled_exception.args)
+        else:
+            msg = "Unhandled %s: %s"
+            msg %= (unhandled_exception.__class__.__name__,
+                    unhandled_exception)
+            msg += "\n" + traceback.format_exc()
+            JobError.__init__(self, msg)
+
+
 class TestBaseException(AutotestError):
     """The parent of all test exceptions."""
     # Children are required to override this.  Never instantiate directly.