Abstract out error backtracing

Signed-off-by: Martin J. Bligh <mbligh@google.com>



git-svn-id: http://test.kernel.org/svn/autotest/trunk@636 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/bin/error.py b/client/bin/error.py
index 6825ae1..8ea71c0 100755
--- a/client/bin/error.py
+++ b/client/bin/error.py
@@ -5,6 +5,15 @@
 import sys
 from traceback import format_exception
 
+def format_error():
+        t, o, tb = sys.exc_info()
+        trace = format_exception(t, o, tb)
+        # Clear the backtrace to prevent a circular reference
+        # in the heap -- as per tutorial
+        tb = ''
+
+        return ''.join(trace)
+
 class JobContinue(SystemExit):
 	"""Allow us to bail out requesting continuance."""
 	pass
@@ -29,14 +38,4 @@
 class UnhandledError(TestError):
 	"""Indicates an unhandled exception in a test."""
 	def __init__(self, prefix):
-		t, o, tb = sys.exc_info()
-		trace = format_exception(t, o, tb)
-		# Clear the backtrace to prevent a circular reference
-		# in the heap -- as per tutorial
-		tb = ''
-
-		msg = prefix
-		for line in trace:
-			msg = msg + line
-
-		self.args = msg
+		self.args = prefix + format_error()