bibble icon indicating copy to clipboard operation
bibble copied to clipboard

Fixing error return for missing month

Open bnlawrence opened this issue 7 years ago • 12 comments

I was getting this

bibble bib/pubs.bib bib/publications.tmpl > _includes/pubs.html
Traceback (most recent call last):
  File "/home/bnl/anaconda2/bin/bibble", line 11, in <module>
    sys.exit(main())
  File "/home/bnl/anaconda2/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/bnl/anaconda2/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/bnl/anaconda2/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/bnl/anaconda2/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/bnl/anaconda2/lib/python2.7/site-packages/bibble/main.py", line 162, in main
    out = tmpl.render(entries=bib_sorted)
  File "/home/bnl/anaconda2/lib/python2.7/site-packages/jinja2/environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/home/bnl/anaconda2/lib/python2.7/site-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "<template>", line 12, in top-level template code
  File "/home/bnl/anaconda2/lib/python2.7/site-packages/bibble/main.py", line 119, in _month_name
    return month_name[int(monthnum)]
jinja2.exceptions.UndefinedError: 'pybtex.database.FieldDict object' has no attribute 'month'

This didn't turn out to be an AttributeError, which was my first attempt, so I gave up and just put a tran for any raw Exception in ... but I think that's probably what you want anyway ... unless you want it to log an error ...

bnlawrence avatar Feb 03 '18 13:02 bnlawrence