diff options
author | Chris Larson <chris_larson@mentor.com> | 2011-05-05 19:06:35 -0700 |
---|---|---|
committer | Chris Larson <chris_larson@mentor.com> | 2011-05-16 12:39:41 -0700 |
commit | 17a64df7e91438ee3fe1f7095c319f700a5372f1 (patch) | |
tree | 227a0832fc4774ae9709b043104ee9e5f75f26a4 /lib | |
parent | ad8ad3fcae29eafbdc09286984495d693a4b73ef (diff) | |
download | openembedded-core-contrib-17a64df7e91438ee3fe1f7095c319f700a5372f1.tar.gz |
bb.exceptions: add to_string convenience function
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bb/exceptions.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/bb/exceptions.py b/lib/bb/exceptions.py index 13269de8c1..e134ae136d 100644 --- a/lib/bb/exceptions.py +++ b/lib/bb/exceptions.py @@ -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) |