From db5e96226d3210b0a728c558082075dd10b76357 Mon Sep 17 00:00:00 2001
From: carlocamilloni <carlo.camilloni@gmail.com>
Date: Tue, 27 Nov 2018 22:02:44 +0100
Subject: [PATCH] change the order of asserts for components make the error
 more informative

---
 src/core/ActionWithValue.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/core/ActionWithValue.cpp b/src/core/ActionWithValue.cpp
index 6ab074034..85b50b3cc 100644
--- a/src/core/ActionWithValue.cpp
+++ b/src/core/ActionWithValue.cpp
@@ -141,9 +141,9 @@ void ActionWithValue::addComponent( const std::string& name ) {
   std::string thename; thename=getLabel() + "." + name;
   for(unsigned i=0; i<values.size(); ++i) {
     plumed_massert(values[i]->name!=getLabel(),"Cannot mix single values with components");
+    plumed_massert(values[i]->name!=thename,"there is already a value with this name: "+thename);
     plumed_massert(values[i]->name!=thename&&name!="bias","Since PLUMED 2.3 the component 'bias' is automatically added to all biases by the general constructor!\n"
                    "Remove the line addComponent(\"bias\") from your bias.");
-    plumed_massert(values[i]->name!=thename,"there is already a value with this name");
   }
   values.emplace_back(new Value(this,thename, false ) );
   std::string msg="  added component to this action:  "+thename+" \n";
@@ -158,9 +158,9 @@ void ActionWithValue::addComponentWithDerivatives( const std::string& name ) {
   std::string thename; thename=getLabel() + "." + name;
   for(unsigned i=0; i<values.size(); ++i) {
     plumed_massert(values[i]->name!=getLabel(),"Cannot mix single values with components");
+    plumed_massert(values[i]->name!=thename,"there is already a value with this name: "+thename);
     plumed_massert(values[i]->name!=thename&&name!="bias","Since PLUMED 2.3 the component 'bias' is automatically added to all biases by the general constructor!\n"
                    "Remove the line addComponentWithDerivatives(\"bias\") from your bias.");
-    plumed_massert(values[i]->name!=thename,"there is already a value with this name");
   }
   values.emplace_back(new Value(this,thename, true ) );
   std::string msg="  added component to this action:  "+thename+" \n";
-- 
GitLab