From 3f99da7159a8122608432bede52d9eee57ec1dbf Mon Sep 17 00:00:00 2001
From: Gabriel Studer <gabriel.studer@stud.unibas.ch>
Date: Fri, 7 Jun 2013 16:03:08 +0200
Subject: [PATCH] Properly check, whether requested compound is valid. No unit
 tests yet.

---
 modules/conop/src/compound_lib_base.cc | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/modules/conop/src/compound_lib_base.cc b/modules/conop/src/compound_lib_base.cc
index 5fda96f37..e5e9c3d09 100644
--- a/modules/conop/src/compound_lib_base.cc
+++ b/modules/conop/src/compound_lib_base.cc
@@ -1,11 +1,19 @@
 #include "compound_lib_base.hh"
+#include <ost/message.hh>
 
 namespace ost { namespace conop {
 
 bool CompoundLibBase::IsResidueComplete(const ost::mol::ResidueHandle& res, bool check_hydrogens, Compound::Dialect dialect) const{
 
   CompoundPtr compound = this->FindCompound(res.GetName(), dialect);
-  AtomSpecList a_spec = compound->GetAtomSpecs();
+  
+  if(!compound){
+    std::stringstream ss;
+    ss << "Could not find " << res.GetName() << " in compound library"; 
+    throw Error(ss.str());
+  }
+
+  const AtomSpecList& a_spec = compound->GetAtomSpecs();
 
   for(AtomSpecList::const_iterator it=a_spec.begin(); it!=a_spec.end();++it){
 
-- 
GitLab