| Submitter | Paul Eggleton |
|---|---|
| Date | Feb. 23, 2012, 3:42 p.m. |
| Message ID | <e22cf3ce86bd3e323c67f0b905b2211efdd334a2.1330011581.git.paul.eggleton@linux.intel.com> |
| Download | mbox | patch |
| Permalink | /patch/21761/ |
| State | New |
| Headers | show |
Comments
On Thu, Feb 23, 2012 at 8:42 AM, Paul Eggleton <paul.eggleton@linux.intel.com> wrote: > except Exception as exc: > - etype, value, tb = sys.exc_info() > - logger.error('Unable to parse %s', value.recipe, > - exc_info=(etype, value, exc.traceback)) > + logger.error('Error during parsing %s: %s\n%s' % (exc.recipe, str(exc), ''.join(bb.exceptions.format_extracted(exc.traceback, limit=5)))) This seems odd to me. Is the UI not displaying the traceback when sent to it via the exc_info? Half the point of coming up with the new traceback format which is pickleable was to allow us to do exception formatting in the UI.
On Thursday 23 February 2012 09:14:16 Chris Larson wrote: > <paul.eggleton@linux.intel.com> wrote: > > except Exception as exc: > > - etype, value, tb = sys.exc_info() > > - logger.error('Unable to parse %s', value.recipe, > > - exc_info=(etype, value, exc.traceback)) > > + logger.error('Error during parsing %s: %s\n%s' % (exc.recipe, > > str(exc), ''.join(bb.exceptions.format_extracted(exc.traceback, > > limit=5)))) > This seems odd to me. Is the UI not displaying the traceback when sent > to it via the exc_info? Half the point of coming up with the new > traceback format which is pickleable was to allow us to do exception > formatting in the UI. Actually that's odd, I could have sworn when I tried this it broke, but it seems to be doing the right thing now. Will send a v2 reverting this part. Presumably you are happy with the rest of it? Cheers, Paul
On Thu, Feb 23, 2012 at 10:23 AM, Paul Eggleton <paul.eggleton@linux.intel.com> wrote: > On Thursday 23 February 2012 09:14:16 Chris Larson wrote: >> <paul.eggleton@linux.intel.com> wrote: >> > except Exception as exc: >> > - etype, value, tb = sys.exc_info() >> > - logger.error('Unable to parse %s', value.recipe, >> > - exc_info=(etype, value, exc.traceback)) >> > + logger.error('Error during parsing %s: %s\n%s' % (exc.recipe, >> > str(exc), ''.join(bb.exceptions.format_extracted(exc.traceback, >> > limit=5)))) >> This seems odd to me. Is the UI not displaying the traceback when sent >> to it via the exc_info? Half the point of coming up with the new >> traceback format which is pickleable was to allow us to do exception >> formatting in the UI. > > Actually that's odd, I could have sworn when I tried this it broke, but it > seems to be doing the right thing now. Will send a v2 reverting this part. > > Presumably you are happy with the rest of it? Yeah, looks fine to me, nice work.
Patch
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index f0778e5..5653874 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py @@ -1605,22 +1605,18 @@ class CookerParser(object): self.shutdown() return False except ParsingFailure as exc: - self.shutdown(clean=False) - bb.fatal('Unable to parse %s: %s' % + logger.error('Unable to parse %s: %s' % (exc.recipe, bb.exceptions.to_string(exc.realexception))) + self.shutdown(clean=False) except (bb.parse.ParseError, bb.data_smart.ExpansionError) as exc: + logger.error(str(exc)) self.shutdown(clean=False) - bb.fatal(str(exc)) except SyntaxError as exc: - self.shutdown(clean=False) logger.error('Unable to parse %s', exc.recipe) - sys.exit(1) + self.shutdown(clean=False) except Exception as exc: - etype, value, tb = sys.exc_info() - logger.error('Unable to parse %s', value.recipe, - exc_info=(etype, value, exc.traceback)) + logger.error('Error during parsing %s: %s\n%s' % (exc.recipe, str(exc), ''.join(bb.exceptions.format_extracted(exc.traceback, limit=5)))) self.shutdown(clean=False) - sys.exit(1) self.current += 1 self.virtuals += len(result)
Fixes a regression introduced in BitBake rev c9f58ef6b897d3fa5b0d23734b5f2cb3dabb057a which prevents errors during parsing from being fully reported because BitBake shuts down before it can print them. Move the error printing to before the shutdown in order to fix it. Also, fix handling of general unexpected exceptions during parsing (i.e. print out a usable stack trace). Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> --- bitbake/lib/bb/cooker.py | 14 +++++--------- 1 files changed, 5 insertions(+), 9 deletions(-)