In
atom_2 is uninitialized if the failure happened while handling
atom_1. So the
except block fails, and since there is no
except on top of it, the whole runtime fails.
for row in bonds:
try:
atom_1 = row["_chem_comp_bond.atom_id_1"]
atom_1_id = atoms_ids.index(atom_1)
atom_2 = row["_chem_comp_bond.atom_id_2"]
atom_2_id = atoms_ids.index(atom_2)
bond_order = helper.bond_pdb_order(row["_chem_comp_bond.value_order"])
mol.AddBond(atom_1_id, atom_2_id, bond_order)
except ValueError:
errors.append(
f"Error perceiving {atom_1} - {atom_2} bond in _chem_comp_bond"
)
except RuntimeError:
errors.append(f"Duplicit bond {atom_1} - {atom_2}")