From 272329de3efe58323cb5645d269abdfebdd41b47 Mon Sep 17 00:00:00 2001 From: Nathan Baker Date: Sat, 21 Nov 2020 17:50:59 -0800 Subject: [PATCH] Make IndexError more verbose. Made #97 easier to trouble-shoot. --- propka/group.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/propka/group.py b/propka/group.py index 17af7e3..e93eb87 100644 --- a/propka/group.py +++ b/propka/group.py @@ -765,7 +765,13 @@ def setup_atoms(self): the_oxygen = self.atom.get_bonded_elements('O') the_nitrogen = self.atom.get_bonded_elements('N') # add protons to the nitrogen - PROTONATOR.protonate_atom(the_nitrogen[0]) + try: + PROTONATOR.protonate_atom(the_nitrogen[0]) + except IndexError: + raise IndexError( + "Unable to find bonded elements for the nitrogen associated " + "with amide group %s" % self.atom + ) the_hydrogens = the_nitrogen[0].get_bonded_elements('H') # set the center using the oxygen and nitrogen amide atoms self.set_center(the_oxygen+the_nitrogen)