From d4b711adb1eca793e5af839ceb7e8f6c67119da5 Mon Sep 17 00:00:00 2001 From: James Graham <J.A.Graham@soton.ac.uk> Date: Fri, 1 Sep 2017 14:10:22 +0100 Subject: [PATCH] Add proper error message if resname is not in database --- pdb2lmp.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pdb2lmp.py b/pdb2lmp.py index 76a748c..fe47c7f 100755 --- a/pdb2lmp.py +++ b/pdb2lmp.py @@ -96,7 +96,10 @@ class PDB2LMP: atnum = 0 for i, mol in enumerate(self.coords.molecules): - dbmol = self.moldb.molecules[mol.name] + try: + dbmol = self.moldb.molecules[mol.name] + except KeyError as e: + raise KeyError("Residue name {0} does not exist in residue database.".format(e)) from None try: nextmol_name = self.coords.molecules[i+1].name except IndexError: -- GitLab