]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
bb.exceptions: add to_string convenience function
authorChris Larson <chris_larson@mentor.com>
Fri, 6 May 2011 02:06:35 +0000 (19:06 -0700)
committerChris Larson <chris_larson@mentor.com>
Mon, 16 May 2011 19:39:41 +0000 (12:39 -0700)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
lib/bb/exceptions.py

index 13269de8c1d4129ce127f533dce7ddbcc2c5e9b4..e134ae136daa78c949d4806d6937a7932f31ee44 100644 (file)
@@ -53,3 +53,9 @@ def format_exception(etype, value, tb, context=1, limit=None, formatter=None):
     formatted.extend(format_extracted(tb, formatter, limit))
     formatted.extend(traceback.format_exception_only(etype, value))
     return formatted
+
+def to_string(exc):
+    if isinstance(exc, SystemExit):
+        if not isinstance(exc.code, basestring):
+            return 'Exited with "%d"' % exc.code
+    return str(exc)