diff options
author | Chris Larson <chris_larson@mentor.com> | 2011-05-05 16:55:33 -0700 |
---|---|---|
committer | Chris Larson <chris_larson@mentor.com> | 2011-05-16 12:39:42 -0700 |
commit | 8c33f50eb68411c071c001331e0134aeb776953b (patch) | |
tree | 4d56318a52728b6a128ba924a529208f235d0fc9 | |
parent | a41c217c6e9195f8b9ea2de6e1d335b10b904558 (diff) | |
download | bitbake-8c33f50eb68411c071c001331e0134aeb776953b.tar.gz |
cooker: pass traceback back from parsing thread
Uses bb.exceptions to get a traceback back from the parsing thread to the main
thread, where it is then formatted. Also enables 3 lines of context for the
formatted traceback, and limits the number of entries displayed to 5.
Signed-off-by: Chris Larson <chris_larson@mentor.com>
-rw-r--r-- | lib/bb/cooker.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py index 95b5db91f..37daf3bb4 100644 --- a/lib/bb/cooker.py +++ b/lib/bb/cooker.py @@ -1026,7 +1026,9 @@ def parse_file(task): try: return True, bb.cache.Cache.parse(filename, appends, parse_file.cfg) except Exception, exc: + tb = sys.exc_info()[2] exc.recipe = filename + exc.traceback = list(bb.exceptions.extract_traceback(tb, context=3)) raise exc # Need to turn BaseExceptions into Exceptions here so we gracefully shutdown # and for example a worker thread doesn't just exit on its own in response to @@ -1119,9 +1121,14 @@ class CookerParser(object): self.shutdown(clean=False) bb.fatal('Error parsing %s: %s' % (exc.recipe, bb.exceptions.to_string(exc.realexception))) - except Exception as exc: + except Exception: + import traceback + etype, value, tb = sys.exc_info() + formatted = bb.exceptions.format_extracted(value.traceback, limit=5) + formatted.extend(traceback.format_exception_only(etype, value)) + self.shutdown(clean=False) - bb.fatal('Error parsing %s: %s' % (exc.recipe, exc)) + bb.fatal('Error parsing %s:\n%s' % (value.recipe, ''.join(formatted))) self.current += 1 self.virtuals += len(result) |