# Copyright 2002-2008 Gentoo Foundation; Distributed under the GPL v2
# $Id: $
+ 07 Sep 2008; Andrew Gaffney <agaffney@gentoo.org> catalyst,
+ +modules/catalyst/util.py:
+ Create catalyst.util module with capture_traceback() and print_traceback()
+ functions Capture and print traceback when build fails instead of letting
+ python do it
+
07 Sep 2008; Andrew Gaffney <agaffney@gentoo.org> catalyst,
modules/catalyst/config.py, modules/catalyst_support.py:
Switch commandline spec value parsing to use catalyst.config.ConfigParser
sys.path.append("./modules")
import catalyst.config
+import catalyst.util
__maintainer__="Chris Gianelloni <wolf31o2@gentoo.org>"
__version__="2.0.6"
mytarget.run()
except:
- # TODO: Capture traceback, so we can display this error after printing of the traceback
+ catalyst.util.print_traceback()
print "!!! catalyst: Error encountered during run of target " + addlargs["target"]
- raise
+ sys.exit(1)
if __name__ == "__main__":
targetmap={}
--- /dev/null
+"""
+Collection of utility functions for catalyst
+"""
+
+import sys, traceback
+
+def capture_traceback():
+ etype, value, tb = sys.exc_info()
+ s = [x.strip() for x in traceback.format_exception(etype, value, tb)]
+ return s
+
+def print_traceback():
+ for x in capture_traceback():
+ print x