BUG: Fix unbound local in exception handling in core/index

Only would occur if both enumerations failed. better way to handle than
try/except.
Merge pull request #5046 from jtratner/fix-unbound-local

BUG: Fix unbound local in exception handling in core/index